您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

记录日志的函数

2025/10/30 14:46:28发布25次查看
打日志 无 /** * 记录用户操作日志 * @param $message 日志消息 * @param $type 日志类型 * @param $level 日志等级 * @return void */function _log($message=array(), $type=debug, $level=log){error_log(sprintf([%s] %s %s\n, $level, date(y/m/d
打日志 /** * 记录用户操作日志 * @param $message 日志消息 * @param $type 日志类型 * @param $level 日志等级 * @return void */function _log($message=array(), $type=debug, $level=log){ error_log(sprintf([%s] %s %s\n, $level, date(y/m/d h:i:s), implode( , $message)) , 3, getlogfile($type));}/** * 创建日志目录文件 app_root/logs/__env__/ymd/ym/{$log_type}_20141111.log * @notice 日志目录必须有读写权限 * @param $log_type 目录 * @return string 写入文件目录 * @constant __env__ 开发环境 * @constant app_root 日志根目录 */function getlogfile($log_type){ $today = time(); $date = date(ymd, $today); $folder_name = substr($date, 0, 6); $fnames = array(__env__, $folder_name, $date); $len = count($fnames); $idx = 0; $filepath = app_root.'logs/'; do { $filepath .= $fnames[$idx++].'/'; if (!file_exists($filepath)) { mkdir($filepath, 0755); } } while($idx < $len); return $filepath.$log_type._.$date..log; }
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product