diff --git a/Test/Config/config-dev.php b/Test/Config/config-dev.php index 0ca05b0f..e5e07b5c 100644 --- a/Test/Config/config-dev.php +++ b/Test/Config/config-dev.php @@ -32,24 +32,33 @@ 'log' => function($name) { $logger = new \Swoolefy\Util\Log($name); $logger->setChannel('application'); - if(isWorkerService()) { - $logPath = LOG_PATH.'/worker.log'; - if (isScriptService()) { - $logPath = LOG_PATH.'/script.log'; - } - $logger->setLogFilePath($logPath); - return $logger; + if(isDaemonService()) { + $logFilePath = LOG_PATH.'/daemon.log'; + }else if (isScriptService()) { + $logFilePath = LOG_PATH.'/script.log'; + }else if (isCronService()) { + $logFilePath = LOG_PATH.'/cron.log'; } else { - $logger->setLogFilePath(LOG_PATH.'/runtime.log'); - return $logger; + $logFilePath = LOG_PATH.'/runtime.log'; } + $logger->setLogFilePath($logFilePath); + return $logger; }, // 系统捕捉异常错误日志 'error_log' => function($name) { $logger = new \Swoolefy\Util\Log($name); $logger->setChannel('application'); - $logger->setLogFilePath(LOG_PATH.'/error.log'); + if(isDaemonService()) { + $logFilePath = LOG_PATH.'/daemon_error.log'; + }else if (isScriptService()) { + $logFilePath = LOG_PATH.'/script_error.log'; + }else if (isCronService()) { + $logFilePath = LOG_PATH.'/cron_error.log'; + } else { + $logFilePath = LOG_PATH.'/error.log'; + } + $logger->setLogFilePath($logFilePath); return $logger; }, diff --git a/swoolefy b/swoolefy index 173faf3a..18a3bab8 100755 --- a/swoolefy +++ b/swoolefy @@ -1094,7 +1094,16 @@ return [ 'log' => function(\$name) { \$logger = new \Swoolefy\Util\Log(\$name); \$logger->setChannel('application'); - \$logger->setLogFilePath(LOG_PATH.'/runtime.log'); + if(isDaemonService()) { + \$logFilePath = LOG_PATH.'/daemon.log'; + }else if (isScriptService()) { + \$logFilePath = LOG_PATH.'/script.log'; + }else if (isCronService()) { + \$logFilePath = LOG_PATH.'/cron.log'; + } else { + \$logFilePath = LOG_PATH.'/runtime.log'; + } + \$logger->setLogFilePath(\$logFilePath); return \$logger; }, @@ -1102,9 +1111,18 @@ return [ 'error_log' => function(\$name) { \$logger = new \Swoolefy\Util\Log(\$name); \$logger->setChannel('application'); - \$logger->setLogFilePath(LOG_PATH.'/error.log'); + if(isDaemonService()) { + \$logFilePath = LOG_PATH.'/daemon_error.log'; + }else if (isScriptService()) { + \$logFilePath = LOG_PATH.'/script_error.log'; + }else if (isCronService()) { + \$logFilePath = LOG_PATH.'/cron_error.log'; + } else { + \$logFilePath = LOG_PATH.'/error.log'; + } + \$logger->setLogFilePath(\$logFilePath); return \$logger; - }, + } ] ];