Skip to content

Commit 6afcc08

Browse files
committed
Use more stable mode soft fail on devdot/monolog-parser
1 parent d4e63fb commit 6afcc08

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
],
2424
"require": {
2525
"php": "^8.0",
26-
"devdot/monolog-parser": "^1.2",
26+
"devdot/monolog-parser": "^1.3",
2727
"illuminate/contracts": "^9",
2828
"illuminate/console": "^9"
2929
},

src/Commands/ShowLog.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ protected function printRecord(LogRecord $record): void {
160160
return;
161161
}
162162
// parse the context object
163-
$array = is_array($record['context']) ? $record['context'] : get_object_vars($record['context']);
163+
// handle the case where context is a string
164+
$array = is_array($record['context'])
165+
? $record['context']
166+
: (is_object($record['context']) ? get_object_vars($record['context']) : ['context' => $record['context']]);
164167
foreach($array as $attribute => $value) {
165168
// handle exception after the loop
166169
if($attribute == 'exception')

src/Models/Log.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public function __construct(string $filename = '') {
1313
// initialize the parser
1414
$this->parser = new Parser();
1515
$this->parser->setPattern(Parser::PATTERN_LARAVEL);
16+
$this->parser->setOptions(Parser::OPTION_JSON_FAIL_SOFT);
1617

1718
if(!empty($filename)) {
1819
$this->setFile($filename);

0 commit comments

Comments
 (0)