forked from luofei614/SocketLog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslog.function.php
More file actions
32 lines (24 loc) · 923 Bytes
/
Copy pathslog.function.php
File metadata and controls
32 lines (24 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require 'slog.class.php';
use think\slog\Slog;
function slog($log, $type = 'log', $css = '')
{
if (is_string($type)) {
$type = preg_replace_callback('/_([a-zA-Z])/', function ($matches) {
return strtoupper($matches[1]);
}, $type);
if (method_exists('\think\slog\Slog', $type) || in_array($type, Slog::$log_types)) {
return call_user_func(['\think\slog\Slog', $type], $log, $css);
}
}
if (is_object($type) && 'mysqli' == get_class($type)) {
return Slog::mysqliLog($log, $type);
}
if (is_resource($type) && ('mysql link' == get_resource_type($type) || 'mysql link persistent' == get_resource_type($type))) {
return Slog::mysqlLog($log, $type);
}
if (is_object($type) && 'PDO' == get_class($type)) {
return Slog::pdoLog($log, $type);
}
throw new Exception($type . ' is not SocketLog method');
}