init
- 框架初始化 - 安装插件 - 修复PHP8.4报错
This commit is contained in:
48
addons/epay/library/v3/Yansongda/Pay/Logger.php
Normal file
48
addons/epay/library/v3/Yansongda/Pay/Logger.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay;
|
||||
|
||||
use Yansongda\Pay\Contract\ConfigInterface;
|
||||
use Yansongda\Pay\Contract\LoggerInterface;
|
||||
use Yansongda\Pay\Exception\ContainerException;
|
||||
use Yansongda\Pay\Exception\InvalidConfigException;
|
||||
use Yansongda\Pay\Exception\ServiceNotFoundException;
|
||||
|
||||
/**
|
||||
* @method static void emergency($message, ?array $context = [])
|
||||
* @method static void alert($message, ?array $context = [])
|
||||
* @method static void critical($message, ?array $context = [])
|
||||
* @method static void error($message, ?array $context = [])
|
||||
* @method static void warning($message, ?array $context = [])
|
||||
* @method static void notice($message, ?array $context = [])
|
||||
* @method static void info($message, ?array $context = [])
|
||||
* @method static void debug($message, ?array $context = [])
|
||||
* @method static void log($message, ?array $context = [])
|
||||
*/
|
||||
class Logger
|
||||
{
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws ServiceNotFoundException
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public static function __callStatic(string $method, ?array $args): void
|
||||
{
|
||||
if (!Pay::hasContainer() || !Pay::has(LoggerInterface::class)
|
||||
|| false === Pay::get(ConfigInterface::class)->get('logger.enable', false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = Pay::get(LoggerInterface::class);
|
||||
|
||||
if ($class instanceof \Psr\Log\LoggerInterface || $class instanceof \Yansongda\Supports\Logger) {
|
||||
$class->{$method}(...$args);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidConfigException(Exception\Exception::LOGGER_CONFIG_ERROR);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user