Skip to content
Browse files

Backported CFileLogRoute code from Yii2

  • Loading branch information...
1 parent cdf7240 commit cfa8fd3eaa49f9a285c5b5208234f365c35e0d61 @samdark samdark committed Jan 29, 2013
Showing with 15 additions and 6 deletions.
  1. +15 −6 framework/logging/CFileLogRoute.php
View
21 framework/logging/CFileLogRoute.php
@@ -135,17 +135,26 @@ public function setMaxLogFiles($value)
*/
protected function processLogs($logs)
{
+ $text='';
+ foreach($logs as $log)
+ $text.=$this->formatLogMessage($log[0],$log[1],$log[2],$log[3]);
+
$logFile=$this->getLogPath().DIRECTORY_SEPARATOR.$this->getLogFile();
$fp=@fopen($logFile,'a');
@flock($fp,LOCK_EX);
if(@filesize($logFile)>$this->getMaxFileSize()*1024)
+ {
$this->rotateFiles();
- $buffer='';
- foreach($logs as $log)
- $buffer.=$this->formatLogMessage($log[0],$log[1],$log[2],$log[3]);
- @fwrite($fp,$buffer);
- @flock($fp,LOCK_UN);
- @fclose($fp);
+ @flock($fp,LOCK_UN);
+ @fclose($fp);

There are code with spaces instead tabs

@samdark
Yii Software LLC member
samdark added a note Jan 31, 2013

Thanks! Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ @file_put_contents($logFile,$text,FILE_APPEND|LOCK_EX);
+ }
+ else
+ {
+ @fwrite($fp,$text);
+ @flock($fp,LOCK_UN);
+ @fclose($fp);
+ }
}
/**

0 comments on commit cfa8fd3

Please sign in to comment.
Something went wrong with that request. Please try again.