This commit is contained in:
2023-04-17 10:19:00 +08:00
parent 00b6d28196
commit e3d990077d
5 changed files with 10 additions and 45 deletions
+5 -3
View File
@@ -10,6 +10,8 @@ use Kiri\Abstracts\Config;
use Kiri\Di\Container;
use Kiri\Di\LocalService;
use Kiri\Environmental;
use Kiri\Error\StdoutLogger;
use Kiri\Error\StdoutLoggerInterface;
use Kiri\Exception\ConfigException;
use Psr\Log\LoggerInterface;
use Swoole\Coroutine;
@@ -74,7 +76,6 @@ class Kiri
/**
* @param $prefix
* @return void
* @throws ConfigException
*/
public static function setProcessName($prefix): void
{
@@ -115,6 +116,7 @@ class Kiri
/**
* @return LocalService
* @throws ReflectionException
*/
public static function service(): LocalService
{
@@ -123,10 +125,10 @@ class Kiri
/**
* @return LoggerInterface
* @return StdoutLogger
* @throws ReflectionException
*/
public static function getLogger(): LoggerInterface
public static function getLogger(): StdoutLogger
{
return static::getContainer()->get(LoggerInterface::class);
}
+3 -3
View File
@@ -14,7 +14,7 @@ use Exception;
use Kiri;
use Kiri\Di\LocalService;
use ReflectionException;
use Kiri\Error\{StdoutLogger, StdoutLoggerInterface};
use Kiri\Error\StdoutLogger;
use Kiri\Exception\{InitException};
use Psr\Log\LoggerInterface;
use Kiri\Events\EventProvider;
@@ -54,12 +54,12 @@ abstract class BaseMain extends Component
/**
* @param array $mapping
* @param array $components
* @throws ReflectionException
*/
public function mapping(array $mapping, array $components)
{
$di = Kiri::getDi();
$di->set(StdoutLoggerInterface::class, StdoutLogger::class);
$di->set(LoggerInterface::class, Logger::class);
$di->set(LoggerInterface::class, StdoutLogger::class);
foreach ($mapping as $interface => $class) {
$di->set($interface, $class);
}
+1 -10
View File
@@ -34,7 +34,6 @@ class Logger implements LoggerInterface
/**
* @param string $message
* @param array $context
* @throws ConfigException
*
* 紧急情况
*/
@@ -48,7 +47,6 @@ class Logger implements LoggerInterface
/**
* @param string $message
* @param array $context
* @throws ConfigException
*
* 应该警惕的
*/
@@ -62,7 +60,6 @@ class Logger implements LoggerInterface
/**
* @param string $message
* @param array $context
* @throws ConfigException
*
* 关键性的日志
*/
@@ -76,7 +73,6 @@ class Logger implements LoggerInterface
/**
* @param string $message
* @param array $context
* @throws ConfigException
*/
public function error($message, array $context = [])
{
@@ -88,7 +84,6 @@ class Logger implements LoggerInterface
/**
* @param string $message
* @param array $context
* @throws ConfigException
*/
public function warning($message, array $context = [])
{
@@ -99,7 +94,6 @@ class Logger implements LoggerInterface
/**
* @param string $message
* @param array $context
* @throws ConfigException
*/
public function notice($message, array $context = [])
{
@@ -111,7 +105,6 @@ class Logger implements LoggerInterface
/**
* @param string $message
* @param array $context
* @throws ConfigException
*/
public function info($message, array $context = [])
{
@@ -123,7 +116,6 @@ class Logger implements LoggerInterface
/**
* @param string $message
* @param array $context
* @throws ConfigException
*/
public function debug($message, array $context = [])
{
@@ -136,8 +128,7 @@ class Logger implements LoggerInterface
* @param mixed $level
* @param string $message
* @param array $context
* @throws ConfigException
* @throws Exception
* @throws
*/
public function log($level, $message, array $context = [])
{
+1 -3
View File
@@ -5,9 +5,8 @@ declare(strict_types=1);
namespace Kiri\Error;
use Kiri\Abstracts\Logger;
use Kiri\Exception\ConfigException;
class StdoutLogger extends Logger implements StdoutLoggerInterface
class StdoutLogger extends Logger
{
@@ -21,7 +20,6 @@ class StdoutLogger extends Logger implements StdoutLoggerInterface
* @param $message
* @param string $model
* @return bool
* @throws ConfigException
*/
public function addError($message, string $model = 'app'): bool
{
@@ -1,26 +0,0 @@
<?php
namespace Kiri\Error;
use Psr\Log\LoggerInterface;
interface StdoutLoggerInterface extends LoggerInterface
{
/**
* @param $message
* @param string $model
* @return bool
*/
public function addError($message, string $model = 'app'): bool;
/**
* @param string $model
* @return mixed
*/
public function getLastError(string $model = 'app'): mixed;
}