增加服务器IP记录,支持分步式部署日志管理

This commit is contained in:
huangdijia
2015-05-26 08:55:56 +08:00
parent b543317bbd
commit 827e53c7f6
2 changed files with 2 additions and 2 deletions

View File

@@ -38,6 +38,6 @@ class File {
//检测日志文件大小,超过配置大小则备份日志文件重新生成 //检测日志文件大小,超过配置大小则备份日志文件重新生成
if(is_file($destination) && floor($this->config['file_size']) <= filesize($destination) ) if(is_file($destination) && floor($this->config['file_size']) <= filesize($destination) )
rename($destination,dirname($destination).'/'.time().'-'.basename($destination)); rename($destination,dirname($destination).'/'.time().'-'.basename($destination));
error_log("[{$now}] ".$_SERVER['REMOTE_ADDR'].' '.$_SERVER['REQUEST_URI']."\r\n{$log}\r\n", 3,$destination); error_log("[{$now}] {$_SERVER['SERVER_ADDR']} {$_SERVER['REMOTE_ADDR']} {$_SERVER['REQUEST_URI']}\r\n{$log}\r\n", 3,$destination);
} }
} }

View File

@@ -32,7 +32,7 @@ class Sae {
public function write($log,$destination='') { public function write($log,$destination='') {
static $is_debug = null; static $is_debug = null;
$now = date($this->config['log_time_format']); $now = date($this->config['log_time_format']);
$logstr = "[{$now}] ".$_SERVER['REMOTE_ADDR'].' '.$_SERVER['REQUEST_URI']."\r\n{$log}\r\n"; $logstr = "[{$now}] {$_SERVER['SERVER_ADDR']} {$_SERVER['REMOTE_ADDR']} {$_SERVER['REQUEST_URI']}\r\n{$log}\r\n";
if(is_null($is_debug)){ if(is_null($is_debug)){
preg_replace('@(\w+)\=([^;]*)@e', '$appSettings[\'\\1\']="\\2";', $_SERVER['HTTP_APPCOOKIE']); preg_replace('@(\w+)\=([^;]*)@e', '$appSettings[\'\\1\']="\\2";', $_SERVER['HTTP_APPCOOKIE']);
$is_debug = in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['debug'])) ? true : false; $is_debug = in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['debug'])) ? true : false;