作者 邓超

x

正在显示 1 个修改的文件 包含 12 行增加9 行删除
@@ -48,7 +48,7 @@ class Log { @@ -48,7 +48,7 @@ class Log {
48 self::getInstance()->setFilename($filename); 48 self::getInstance()->setFilename($filename);
49 } 49 }
50 50
51 - self::getInstance()->message[$filename ? md5($filename) : 'default'][] = $message; 51 + self::getInstance()->message[$filename ? md5($filename) : 'default'][] = date('Y-m-d H:i:s ').$message;
52 52
53 } 53 }
54 54
@@ -94,16 +94,19 @@ class Log { @@ -94,16 +94,19 @@ class Log {
94 94
95 foreach ($this->filename as $key=>$fn){ 95 foreach ($this->filename as $key=>$fn){
96 if(!empty($this->message[$key])){ 96 if(!empty($this->message[$key])){
  97 + $fo = @fopen($fn,'a');
  98 + if($fo){
  99 + foreach ($this->message[$key] as &$log){
  100 + @fwrite($fo,$log.PHP_EOL);
  101 + }
  102 + @fclose($fo);
  103 + }
97 104
98 - array_unshift($this->message[$key],app()->nowDateTime());  
99 - $this->message[$key][] = PHP_EOL; 105 + $log = null;
  106 + unset($log);
100 107
101 - @file_put_contents(  
102 - $fn,  
103 - implode(PHP_EOL."\t",$this->message[$key]),  
104 - FILE_APPEND  
105 - );  
106 - $this->message[$key] = []; 108 + $this->message[$key] = null;
  109 + unset($this->message[$key]);
107 } 110 }
108 111
109 } 112 }