变更
This commit is contained in:
@@ -10,6 +10,8 @@ use Kiri\Abstracts\Config;
|
|||||||
use Kiri\Di\Container;
|
use Kiri\Di\Container;
|
||||||
use Kiri\Di\LocalService;
|
use Kiri\Di\LocalService;
|
||||||
use Kiri\Environmental;
|
use Kiri\Environmental;
|
||||||
|
use Kiri\Error\StdoutLogger;
|
||||||
|
use Kiri\Error\StdoutLoggerInterface;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
@@ -74,7 +76,6 @@ class Kiri
|
|||||||
/**
|
/**
|
||||||
* @param $prefix
|
* @param $prefix
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ConfigException
|
|
||||||
*/
|
*/
|
||||||
public static function setProcessName($prefix): void
|
public static function setProcessName($prefix): void
|
||||||
{
|
{
|
||||||
@@ -115,6 +116,7 @@ class Kiri
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return LocalService
|
* @return LocalService
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public static function service(): LocalService
|
public static function service(): LocalService
|
||||||
{
|
{
|
||||||
@@ -123,10 +125,10 @@ class Kiri
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return LoggerInterface
|
* @return StdoutLogger
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public static function getLogger(): LoggerInterface
|
public static function getLogger(): StdoutLogger
|
||||||
{
|
{
|
||||||
return static::getContainer()->get(LoggerInterface::class);
|
return static::getContainer()->get(LoggerInterface::class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use Exception;
|
|||||||
use Kiri;
|
use Kiri;
|
||||||
use Kiri\Di\LocalService;
|
use Kiri\Di\LocalService;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Kiri\Error\{StdoutLogger, StdoutLoggerInterface};
|
use Kiri\Error\StdoutLogger;
|
||||||
use Kiri\Exception\{InitException};
|
use Kiri\Exception\{InitException};
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Kiri\Events\EventProvider;
|
use Kiri\Events\EventProvider;
|
||||||
@@ -54,12 +54,12 @@ abstract class BaseMain extends Component
|
|||||||
/**
|
/**
|
||||||
* @param array $mapping
|
* @param array $mapping
|
||||||
* @param array $components
|
* @param array $components
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function mapping(array $mapping, array $components)
|
public function mapping(array $mapping, array $components)
|
||||||
{
|
{
|
||||||
$di = Kiri::getDi();
|
$di = Kiri::getDi();
|
||||||
$di->set(StdoutLoggerInterface::class, StdoutLogger::class);
|
$di->set(LoggerInterface::class, StdoutLogger::class);
|
||||||
$di->set(LoggerInterface::class, Logger::class);
|
|
||||||
foreach ($mapping as $interface => $class) {
|
foreach ($mapping as $interface => $class) {
|
||||||
$di->set($interface, $class);
|
$di->set($interface, $class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ class Logger implements LoggerInterface
|
|||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $context
|
* @param array $context
|
||||||
* @throws ConfigException
|
|
||||||
*
|
*
|
||||||
* 紧急情况
|
* 紧急情况
|
||||||
*/
|
*/
|
||||||
@@ -48,7 +47,6 @@ class Logger implements LoggerInterface
|
|||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $context
|
* @param array $context
|
||||||
* @throws ConfigException
|
|
||||||
*
|
*
|
||||||
* 应该警惕的
|
* 应该警惕的
|
||||||
*/
|
*/
|
||||||
@@ -62,7 +60,6 @@ class Logger implements LoggerInterface
|
|||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $context
|
* @param array $context
|
||||||
* @throws ConfigException
|
|
||||||
*
|
*
|
||||||
* 关键性的日志
|
* 关键性的日志
|
||||||
*/
|
*/
|
||||||
@@ -76,7 +73,6 @@ class Logger implements LoggerInterface
|
|||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $context
|
* @param array $context
|
||||||
* @throws ConfigException
|
|
||||||
*/
|
*/
|
||||||
public function error($message, array $context = [])
|
public function error($message, array $context = [])
|
||||||
{
|
{
|
||||||
@@ -88,7 +84,6 @@ class Logger implements LoggerInterface
|
|||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $context
|
* @param array $context
|
||||||
* @throws ConfigException
|
|
||||||
*/
|
*/
|
||||||
public function warning($message, array $context = [])
|
public function warning($message, array $context = [])
|
||||||
{
|
{
|
||||||
@@ -99,7 +94,6 @@ class Logger implements LoggerInterface
|
|||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $context
|
* @param array $context
|
||||||
* @throws ConfigException
|
|
||||||
*/
|
*/
|
||||||
public function notice($message, array $context = [])
|
public function notice($message, array $context = [])
|
||||||
{
|
{
|
||||||
@@ -111,7 +105,6 @@ class Logger implements LoggerInterface
|
|||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $context
|
* @param array $context
|
||||||
* @throws ConfigException
|
|
||||||
*/
|
*/
|
||||||
public function info($message, array $context = [])
|
public function info($message, array $context = [])
|
||||||
{
|
{
|
||||||
@@ -123,7 +116,6 @@ class Logger implements LoggerInterface
|
|||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $context
|
* @param array $context
|
||||||
* @throws ConfigException
|
|
||||||
*/
|
*/
|
||||||
public function debug($message, array $context = [])
|
public function debug($message, array $context = [])
|
||||||
{
|
{
|
||||||
@@ -136,8 +128,7 @@ class Logger implements LoggerInterface
|
|||||||
* @param mixed $level
|
* @param mixed $level
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $context
|
* @param array $context
|
||||||
* @throws ConfigException
|
* @throws
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function log($level, $message, array $context = [])
|
public function log($level, $message, array $context = [])
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ declare(strict_types=1);
|
|||||||
namespace Kiri\Error;
|
namespace Kiri\Error;
|
||||||
|
|
||||||
use Kiri\Abstracts\Logger;
|
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 $message
|
||||||
* @param string $model
|
* @param string $model
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws ConfigException
|
|
||||||
*/
|
*/
|
||||||
public function addError($message, string $model = 'app'): bool
|
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;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user