/**
* 日志记录
*
* @param string $type
* @param mixed $msg
*/
function logger($type, $msg)
{
if (!is_string($msg)) {
$msg = json_encode($msg);
}
$data = array_merge($_GET, $_POST);
$url = explode('?', $_SERVER['REQUEST_URI'])[0] . '?' . urldecode(http_build_query($data));
$ip = ip_address();
$pid = function_exists('posix_getpid') ? posix_getpid() : '0';
$content = sprintf("[%s]%s,%s,%s|%s|%s\r\n", date('Y-m-d H:i:s'), $uid, $ip, $pid, $msg, $url);
$type = str_replace(':', '_', strtolower($type));
$file = '/data/logs/' . $_SERVER["HTTP_HOST"] . '/' . $type . date('Ymd') . '.log';
is_dir(dirname($file)) or mkdir(dirname($file), 0755, true);
file_put_contents($file, $content, FILE_APPEND);
}
* 日志记录
*
* @param string $type
* @param mixed $msg
*/
function logger($type, $msg)
{
if (!is_string($msg)) {
$msg = json_encode($msg);
}
$data = array_merge($_GET, $_POST);
$url = explode('?', $_SERVER['REQUEST_URI'])[0] . '?' . urldecode(http_build_query($data));
$ip = ip_address();
$pid = function_exists('posix_getpid') ? posix_getpid() : '0';
$content = sprintf("[%s]%s,%s,%s|%s|%s\r\n", date('Y-m-d H:i:s'), $uid, $ip, $pid, $msg, $url);
$type = str_replace(':', '_', strtolower($type));
$file = '/data/logs/' . $_SERVER["HTTP_HOST"] . '/' . $type . date('Ymd') . '.log';
is_dir(dirname($file)) or mkdir(dirname($file), 0755, true);
file_put_contents($file, $content, FILE_APPEND);
}