diff --git a/config/log.php b/config/log.php index b6c0e6c59..ee8448c4a 100644 --- a/config/log.php +++ b/config/log.php @@ -16,11 +16,23 @@ return [ 'default' => [ 'handlers' => [ [ - 'class' => Monolog\Handler\RotatingFileHandler::class, + // 'class' => Monolog\Handler\RotatingFileHandler::class, + // 'constructor' => [ + // runtime_path() . '/logs/'.date('Ym').'/.log', + // 2048, + // Monolog\Logger::INFO, + // true, + // 0755 + // ], + // 'formatter' => [ + // 'class' => Monolog\Formatter\LineFormatter::class, + // 'constructor' => [null, 'Y-m-d H:i:s', true,true], + // ], + 'class' => \support\log\MonologExtendHandler::class, 'constructor' => [ - runtime_path() . '/logs/'.date('Ym').'/.log', + null, 2048, - Monolog\Logger::INFO, + Monolog\Logger::DEBUG, true, 0755 ], diff --git a/config/plugin/webman/redis-queue/log.php b/config/plugin/webman/redis-queue/log.php index c50153649..b44d71694 100644 --- a/config/plugin/webman/redis-queue/log.php +++ b/config/plugin/webman/redis-queue/log.php @@ -19,8 +19,10 @@ return [ 'class' => \support\log\MonologExtendHandler::class, 'constructor' => [ 'redis-queue', - 7, //$maxFiles - Monolog\Logger::NOTICE, + 2048, + Monolog\Logger::DEBUG, + true, + 0755 ], 'formatter' => [ 'class' => Monolog\Formatter\LineFormatter::class, diff --git a/support/log/MonologExtendHandler.php b/support/log/MonologExtendHandler.php index 5aec547af..608ba08ad 100644 --- a/support/log/MonologExtendHandler.php +++ b/support/log/MonologExtendHandler.php @@ -1,11 +1,15 @@ runtimeLogPath = runtime_path() . '/logs/'; $this->channelDirName = $channelDirName; + $this->level=$level; $dateDir = date('Ym').'/'; $filename = date('d') .'.log'; $fullFilePath = empty($channelDirName) ? $this->runtimeLogPath . $dateDir .$filename : $this->runtimeLogPath . $this->channelDirName . '/' . $dateDir . $filename; @@ -97,12 +103,16 @@ class MonologExtendHandler extends StreamHandler } $dateDir = date('Ym') . '/'; $logBasePath = empty($this->channelDirName) ? $this->runtimeLogPath . $dateDir : $this->runtimeLogPath . $this->channelDirName . '/' . $dateDir; - $filename = date('d').'.log'; + if($this->level==200){ + $filename = date('d').'.log'; + }else{ + $filename = date('d').'_error.log'; + } $fullLogFilename = $logBasePath . $filename; // archive latest file clearstatcache(true, $fullLogFilename); if (file_exists($fullLogFilename)) { - $target = $logBasePath. date('Y-m') . '_' . $filename; + $target = $logBasePath. $filename; rename($fullLogFilename, $target); }else{ if (!is_dir($logBasePath))