mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-22 17:16:18 +02:00
Code cleanups
This commit is contained in:
@@ -47,11 +47,11 @@ class GitProcessor implements ProcessorInterface
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
// return if the level is not high enough
|
||||
if ($record['level'] < $this->level) {
|
||||
if ($record->level < $this->level) {
|
||||
return $record;
|
||||
}
|
||||
|
||||
$record['extra']['git'] = self::getGitInfo();
|
||||
$record->extra['git'] = self::getGitInfo();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ class HostnameProcessor implements ProcessorInterface
|
||||
*/
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
$record['extra']['hostname'] = self::$host;
|
||||
$record->extra['hostname'] = self::$host;
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
@@ -31,14 +31,14 @@ use Monolog\LogRecord;
|
||||
*/
|
||||
class IntrospectionProcessor implements ProcessorInterface
|
||||
{
|
||||
/** @var int */
|
||||
private $level;
|
||||
private int $level;
|
||||
|
||||
/** @var string[] */
|
||||
private $skipClassesPartials;
|
||||
/** @var int */
|
||||
private $skipStackFramesCount;
|
||||
/** @var string[] */
|
||||
private $skipFunctions = [
|
||||
private array $skipClassesPartials;
|
||||
|
||||
private int $skipStackFramesCount;
|
||||
|
||||
private const SKIP_FUNCTIONS = [
|
||||
'call_user_func',
|
||||
'call_user_func_array',
|
||||
];
|
||||
@@ -62,7 +62,7 @@ class IntrospectionProcessor implements ProcessorInterface
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
// return if the level is not high enough
|
||||
if ($record['level'] < $this->level) {
|
||||
if ($record->level < $this->level) {
|
||||
return $record;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class IntrospectionProcessor implements ProcessorInterface
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
} elseif (in_array($trace[$i]['function'], $this->skipFunctions)) {
|
||||
} elseif (in_array($trace[$i]['function'], self::SKIP_FUNCTIONS)) {
|
||||
$i++;
|
||||
|
||||
continue;
|
||||
@@ -96,8 +96,8 @@ class IntrospectionProcessor implements ProcessorInterface
|
||||
$i += $this->skipStackFramesCount;
|
||||
|
||||
// we should have the call source now
|
||||
$record['extra'] = array_merge(
|
||||
$record['extra'],
|
||||
$record->extra = array_merge(
|
||||
$record->extra,
|
||||
[
|
||||
'file' => isset($trace[$i - 1]['file']) ? $trace[$i - 1]['file'] : null,
|
||||
'line' => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null,
|
||||
@@ -111,7 +111,7 @@ class IntrospectionProcessor implements ProcessorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array[] $trace
|
||||
* @param array<mixed> $trace
|
||||
*/
|
||||
private function isTraceClassOrSkippedFunction(array $trace, int $index): bool
|
||||
{
|
||||
@@ -119,6 +119,6 @@ class IntrospectionProcessor implements ProcessorInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions);
|
||||
return isset($trace[$index]['class']) || in_array($trace[$index]['function'], self::SKIP_FUNCTIONS);
|
||||
}
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ class MemoryPeakUsageProcessor extends MemoryProcessor
|
||||
$usage = $this->formatBytes($usage);
|
||||
}
|
||||
|
||||
$record['extra']['memory_peak_usage'] = $usage;
|
||||
$record->extra['memory_peak_usage'] = $usage;
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ class MemoryUsageProcessor extends MemoryProcessor
|
||||
$usage = $this->formatBytes($usage);
|
||||
}
|
||||
|
||||
$record['extra']['memory_usage'] = $usage;
|
||||
$record->extra['memory_usage'] = $usage;
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
@@ -46,11 +46,11 @@ class MercurialProcessor implements ProcessorInterface
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
// return if the level is not high enough
|
||||
if ($record['level'] < $this->level) {
|
||||
if ($record->level < $this->level) {
|
||||
return $record;
|
||||
}
|
||||
|
||||
$record['extra']['hg'] = self::getMercurialInfo();
|
||||
$record->extra['hg'] = self::getMercurialInfo();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ class ProcessIdProcessor implements ProcessorInterface
|
||||
*/
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
$record['extra']['process_id'] = getmypid();
|
||||
$record->extra['process_id'] = getmypid();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
@@ -46,16 +46,16 @@ class PsrLogMessageProcessor implements ProcessorInterface
|
||||
*/
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
if (false === strpos($record['message'], '{')) {
|
||||
if (false === strpos($record->message, '{')) {
|
||||
return $record;
|
||||
}
|
||||
|
||||
$replacements = [];
|
||||
$context = $record['context'];
|
||||
$context = $record->context;
|
||||
|
||||
foreach ($context as $key => $val) {
|
||||
$placeholder = '{' . $key . '}';
|
||||
if (strpos($record['message'], $placeholder) === false) {
|
||||
if (strpos($record->message, $placeholder) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,6 @@ class PsrLogMessageProcessor implements ProcessorInterface
|
||||
}
|
||||
}
|
||||
|
||||
return $record->with(message: strtr($record['message'], $replacements), context: $context);
|
||||
return $record->with(message: strtr($record->message, $replacements), context: $context);
|
||||
}
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ class UidProcessor implements ProcessorInterface, ResettableInterface
|
||||
*/
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
$record['extra']['uid'] = $this->uid;
|
||||
$record->extra['uid'] = $this->uid;
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
@@ -86,7 +86,7 @@ class WebProcessor implements ProcessorInterface
|
||||
return $record;
|
||||
}
|
||||
|
||||
$record['extra'] = $this->appendExtraFields($record['extra']);
|
||||
$record->extra = $this->appendExtraFields($record->extra);
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
Reference in New Issue
Block a user