变更
This commit is contained in:
@@ -32,6 +32,16 @@ class Logger implements LoggerInterface
|
|||||||
const LOGGER_LEVELS = [Logger::EMERGENCY, Logger::ALERT, Logger::CRITICAL, Logger::ERROR, Logger::WARNING, Logger::NOTICE, Logger::INFO, Logger::DEBUG];
|
const LOGGER_LEVELS = [Logger::EMERGENCY, Logger::ALERT, Logger::CRITICAL, Logger::ERROR, Logger::WARNING, Logger::NOTICE, Logger::INFO, Logger::DEBUG];
|
||||||
|
|
||||||
|
|
||||||
|
private array $levels = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->levels = Config::get('log.level', Logger::LOGGER_LEVELS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $context
|
* @param array $context
|
||||||
@@ -131,11 +141,9 @@ class Logger implements LoggerInterface
|
|||||||
* @param array $context
|
* @param array $context
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
public function log($level, $message, array $context = [])
|
public function log($level, $message, array $context = []): void
|
||||||
{
|
{
|
||||||
// TODO: Implement log() method.
|
if (!in_array($level, $this->levels)) {
|
||||||
$levels = Config::get('log.level', Logger::LOGGER_LEVELS);
|
|
||||||
if (!in_array($level, $levels)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$_string = "[" . now() . ']' . ucfirst($level) . ": " . $message . PHP_EOL;
|
$_string = "[" . now() . ']' . ucfirst($level) . ": " . $message . PHP_EOL;
|
||||||
|
|||||||
Reference in New Issue
Block a user