Skip to content

Commit

Permalink
feat: update monolog ^3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
onanying committed Apr 18, 2023
1 parent 2738493 commit 6640b32
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Container/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\HandlerInterface;
use Monolog\Handler\RotatingFileHandler;
use Monolog\LogRecord;

/**
* Class Logger
Expand Down Expand Up @@ -51,24 +52,24 @@ public static function instance(): \Monolog\Logger
}

/**
* @param array $record
* @param LogRecord $record
* @return bool
*/
public function isHandling(array $record): bool
public function isHandling(LogRecord $record): bool
{
if (APP_DEBUG) {
return $record['level'] >= \Monolog\Logger::DEBUG;
return $record->level->toRFC5424Level() >= \Monolog\Level::Debug;
}
return $record['level'] >= \Monolog\Logger::INFO;
return $record->level->toRFC5424Level() >= \Monolog\Level::Info;
}

/**
* @param array $record
* @param LogRecord $record
* @return bool
*/
public function handle(array $record): bool
public function handle(LogRecord $record): bool
{
$message = sprintf("%s %s %s\n", $record['datetime']->format('Y-m-d H:i:s.u'), $record['level_name'], $record['message']);
$message = sprintf("%s %s %s\n", $record->datetime->format('Y-m-d H:i:s.u'), $record->level->toPsrLogLevel(), $record->message);
switch (PHP_SAPI) {
case 'cli':
case 'cli-server':
Expand Down

0 comments on commit 6640b32

Please sign in to comment.