Skip to content

Commit 44c767c

Browse files
authored
Merge pull request #6654 from ddevsr/refactor-logger
refactor: move print_r to interpolate and use clean_path
2 parents c7a47fa + 7aead5d commit 44c767c

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

system/Log/Logger.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,6 @@ public function log($level, $message, array $context = []): bool
265265
// Parse our placeholders
266266
$message = $this->interpolate($message, $context);
267267

268-
if (! is_string($message)) {
269-
$message = print_r($message, true);
270-
}
271-
272268
if ($this->cacheLogs) {
273269
$this->logCache[] = [
274270
'level' => $level,
@@ -319,7 +315,7 @@ public function log($level, $message, array $context = []): bool
319315
protected function interpolate($message, array $context = [])
320316
{
321317
if (! is_string($message)) {
322-
return $message;
318+
return print_r($message, true);
323319
}
324320

325321
// build a replacement array with braces around the context keys
@@ -329,7 +325,7 @@ protected function interpolate($message, array $context = [])
329325
// Verify that the 'exception' key is actually an exception
330326
// or error, both of which implement the 'Throwable' interface.
331327
if ($key === 'exception' && $val instanceof Throwable) {
332-
$val = $val->getMessage() . ' ' . $this->cleanFileNames($val->getFile()) . ':' . $val->getLine();
328+
$val = $val->getMessage() . ' ' . clean_path($val->getFile()) . ':' . $val->getLine();
333329
}
334330

335331
// todo - sanitize input before writing to file?

0 commit comments

Comments
 (0)