Skip to content

Commit a166678

Browse files
committed
Enhance logger to properly include global context
1 parent 30cdc19 commit a166678

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

system/Log/Logger.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,10 @@ public function log($level, string|Stringable $message, array $context = []): vo
264264
$message = $this->interpolate($message, $context);
265265

266266
if ($this->logGlobalContext) {
267-
$message .= ' ' . json_encode(service('context')->getAll());
267+
$globalContext = service('context')->getAll();
268+
if (is_array($globalContext) && $globalContext !== []) {
269+
$message .= ' ' . json_encode($globalContext);
270+
}
268271
}
269272

270273
if ($this->cacheLogs) {

0 commit comments

Comments
 (0)