时时商务社区
标题:
PHP中设置时区,记录日志文件的实现代码
[打印本页]
作者:
qz234
时间:
2018-2-14 08:26
[U]复制代码[/U] 代码如下:
getMessage());
}
//record operation log into .log file
function logger($log_content)
{
print_r(date('H:i:s')." ".$log_content."
");
$log_filename = date("Ymd").".log";
$file = fopen($log_filename ,"a+");
fwrite($file, date('H:i:s')." ".$log_content."\r\n");
fclose($file);
}
//record operation log into .log file
function logger2($log_content)
{
Global $max_size;
print_r(date('H:i:s')." ".$log_content." "."
");
$log_filename = date("Ymd").".log";
if(file_exists($log_filename) and (abs(filesize($log_filename)) > $max_size)){unlink($log_filename);sleep(1);}
file_put_contents($log_filename, date('H:i:s')." ".$log_content." "."\r\n", FILE_APPEND);
}
//error handler function
function myHandler($level, $message, $file, $line, $context)
{
logger("
[ERROR]
LEVEL: $level, MESSAGE: $message, FILE: $file, LINE: $line, CONTENT: $context");
die();
}
?>
原文网址:http://txw1958.cnblogs.com/
您可能感兴趣的文章:
有关 PHP 和 MySQL 时区的一点总结
PHP中设置时区方法小结
PHP跨时区(UTC时间)应用解决方案
深入解析PHP 5.3.x 的strtotime() 时区设定 警告信息修复
php时区转换转换函数
PHP中date与gmdate的区别及默认时区设置
javascript+php实现根据用户时区显示当地时间的方法
php输出全球各个时区列表的方法
PHP中遇到的时区问题解决方法
欢迎光临 时时商务社区 (http://bbs.4435.cn/)
Powered by Discuz! X3.2