改名
This commit is contained in:
@@ -7,7 +7,6 @@ use Exception;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Server\Events\OnAfterRequest;
|
||||
use Server\Events\OnWorkerStop;
|
||||
|
||||
|
||||
@@ -44,7 +43,6 @@ class Logger implements LoggerInterface
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->eventProvider->on(OnAfterRequest::class, [$this, 'onAfterRequest']);
|
||||
$this->eventProvider->on(OnWorkerStop::class, [$this, 'onAfterRequest']);
|
||||
}
|
||||
|
||||
@@ -56,7 +54,7 @@ class Logger implements LoggerInterface
|
||||
*
|
||||
* 紧急情况
|
||||
*/
|
||||
public function emergency($message, array $context = array())
|
||||
public function emergency($message, array $context = [])
|
||||
{
|
||||
// TODO: Implement emergency() method.
|
||||
$this->log(Logger::EMERGENCY, $message, $context);
|
||||
@@ -70,7 +68,7 @@ class Logger implements LoggerInterface
|
||||
*
|
||||
* 应该警惕的
|
||||
*/
|
||||
public function alert($message, array $context = array())
|
||||
public function alert($message, array $context = [])
|
||||
{
|
||||
// TODO: Implement alert() method.
|
||||
$this->log(Logger::ALERT, $message, $context);
|
||||
@@ -84,7 +82,7 @@ class Logger implements LoggerInterface
|
||||
*
|
||||
* 关键性的日志
|
||||
*/
|
||||
public function critical($message, array $context = array())
|
||||
public function critical($message, array $context = [])
|
||||
{
|
||||
// TODO: Implement critical() method.
|
||||
$this->log(Logger::CRITICAL, $message, $context);
|
||||
@@ -96,7 +94,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context
|
||||
* @throws ConfigException
|
||||
*/
|
||||
public function error($message, array $context = array())
|
||||
public function error($message, array $context = [])
|
||||
{
|
||||
// TODO: Implement error() method.
|
||||
$this->log(Logger::ERROR, $message, $context);
|
||||
@@ -108,7 +106,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context
|
||||
* @throws ConfigException
|
||||
*/
|
||||
public function warning($message, array $context = array())
|
||||
public function warning($message, array $context = [])
|
||||
{
|
||||
// TODO: Implement warning() method.
|
||||
$this->log(Logger::WARNING, $message, $context);
|
||||
@@ -119,7 +117,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context
|
||||
* @throws ConfigException
|
||||
*/
|
||||
public function notice($message, array $context = array())
|
||||
public function notice($message, array $context = [])
|
||||
{
|
||||
// TODO: Implement notice() method.
|
||||
$this->log(Logger::NOTICE, $message, $context);
|
||||
@@ -131,7 +129,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context
|
||||
* @throws ConfigException
|
||||
*/
|
||||
public function info($message, array $context = array())
|
||||
public function info($message, array $context = [])
|
||||
{
|
||||
// TODO: Implement info() method.
|
||||
$this->log(Logger::INFO, $message, $context);
|
||||
@@ -143,7 +141,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context
|
||||
* @throws ConfigException
|
||||
*/
|
||||
public function debug($message, array $context = array())
|
||||
public function debug($message, array $context = [])
|
||||
{
|
||||
// TODO: Implement debug() method.
|
||||
$this->log(Logger::DEBUG, $message, $context);
|
||||
@@ -156,7 +154,7 @@ class Logger implements LoggerInterface
|
||||
* @param array $context
|
||||
* @throws ConfigException
|
||||
*/
|
||||
public function log($level, $message, array $context = array())
|
||||
public function log($level, $message, array $context = [])
|
||||
{
|
||||
// TODO: Implement log() method.
|
||||
$levels = Config::get('log.level', Logger::LOGGER_LEVELS);
|
||||
@@ -173,10 +171,10 @@ class Logger implements LoggerInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param OnAfterRequest|OnWorkerStop $param
|
||||
* @param OnWorkerStop $param
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onAfterRequest(OnAfterRequest|OnWorkerStop $param)
|
||||
public function onAfterRequest(OnWorkerStop $param)
|
||||
{
|
||||
$loggers = implode(PHP_EOL, $this->_loggers);
|
||||
$this->_loggers = [];
|
||||
@@ -195,6 +193,9 @@ class Logger implements LoggerInterface
|
||||
*/
|
||||
private function _string($message, $context): string
|
||||
{
|
||||
if (!empty($context)) {
|
||||
return $message . ' ' . print_r($context, true) . PHP_EOL;
|
||||
}
|
||||
return $message . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user