php记录日志方法
来源:互联网 发布:php 二进制打印出来 编辑:程序博客网 时间:2024/06/07 06:29
/**
* 日志记录
*
* @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);
}
0 0
- php记录日志方法
- PHP日志记录方法
- php记录自定义log日志方法
- php日志,记录日志
- 记录PHP错误日志
- php记录日志
- 记录PHP错误日志
- PHP 记录日志方式
- php日志记录
- PHP设置时区,记录日志文件的方法
- PHP设置时区,记录日志文件的方法
- php项目中常用的log日志记录方法
- php中记录日志的几种方法
- 日志记录方法
- AIR日志记录方法
- JAVA日志记录方法
- 日志记录方法总结
- PHP 日志记录功能实现
- 光耦参数
- Ubuntu12.04下samba配置与qt4.8.6安装
- ostream_iterator详细解析
- 虚拟机镜像相关操作
- 关于myeclipse安装extjs4.2提示插件spket遇到的一些问题及解决办法
- php记录日志方法
- IHttpModule.Init方法被执行多次的原因
- Android实例demo1之查看手机内存状态、时间数据大小格式化
- mysql查询表字段信息
- 数据结构之共享栈(顺序存储)—改编《大话数据结构》
- HDU 3896 Greast TC 倍增lca,dfn,low,fin的运用
- jpg/png格式图片转eps格式的方法总结
- GEC210 烧写裸机程序到SD卡、flash
- Struts2访问Web元素(RequestAware,SessionAware,ApplicationAware)