This commit is contained in:
2021-08-24 19:12:59 +08:00
parent 1ef28546b9
commit 57d8e44fef
3 changed files with 15 additions and 23 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ class Logger implements LoggerInterface
* @param array $context
* @throws ConfigException
*/
private function log($level, $message, array $context = array())
public function log($level, $message, array $context = array())
{
// TODO: Implement log() method.
$levels = Config::get('log.level', Logger::LOGGER_LEVELS);
+14 -21
View File
@@ -12,13 +12,10 @@ namespace Kiri\Error;
use Annotation\Inject;
use Exception;
use Kiri\Abstracts\Component;
use Kiri\Abstracts\Config;
use Kiri\Core\Json;
use Kiri\Events\EventProvider;
use Kiri\Exception\ConfigException;
use Kiri\Kiri;
use Psr\Log\LoggerInterface;
use Swoole\Coroutine;
use Throwable;
/**
@@ -77,24 +74,6 @@ class Logger extends Component
}
/**
* @throws Exception
* 写入日志
*/
public function insert()
{
if (empty($this->logs)) {
return;
}
foreach ($this->logs as $method => $message) {
$this->write($message, $method);
}
$this->logs = [];
}
/**
* @param Throwable $exception
* @return mixed
@@ -114,5 +93,19 @@ class Logger extends Component
}
/**
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call(string $name, array $arguments): mixed
{
if (!method_exists($this, $name)) {
return $this->logger->{$name}(...$arguments);
} else {
return $this->{$name}(...$arguments);
}
}
}
-1
View File
@@ -26,7 +26,6 @@ abstract class HttpService extends Component
{
$logger = Kiri::app()->getLogger();
$logger->write($message, $category);
$logger->insert();
}
/**