zhamao-framework/src/ZM/Bootstrap/RegisterLogger.php
2023-02-18 20:56:47 +08:00

23 lines
629 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
namespace ZM\Bootstrap;
use ZM\Logger\ConsoleLogger;
class RegisterLogger
{
public function bootstrap(array $config): void
{
// 初始化 Logger
if (!ob_logger_registered()) {
$debug = $config['verbose'] ?? false;
$debug = $debug ? 'debug' : null;
// 如果没有注册过 Logger那么就初始化一个在启动框架前注册的话就不会初始化了可替换为其他 Logger
$logger = new ConsoleLogger($config['log-level'] ?? $debug ?? 'info');
ob_logger_register($logger);
}
}
}