Skip to content

Commit 4fc5acd

Browse files
author
Sébastien HEYD
committed
refactor(logs): improve log parsing and message formatting in LogFile model
- Replace absolute paths with relative paths in log messages using base_path() - Simplify stacktrace processing logic by removing unnecessary conditionals - Set errorLineNumber immediately when log entry is created instead of complex detection - Remove redundant '[stacktrace]' line detection and pattern matching checks
1 parent 07abb6d commit 4fc5acd

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/Models/LogFile.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,13 @@ protected function formatContent($content)
9090
'date' => Date::createFromFormat('Y-m-d H:i:s', $matches['date']),
9191
'env' => $matches['env'],
9292
'type' => $matches['type'],
93-
'message' => $matches['message'],
93+
'message' => str_replace(base_path(), '', $matches['message']),
9494
'stacktrace' => [],
9595
];
96-
}
97-
98-
if ($line === '[stacktrace]' || $errorLineNumber !== false) {
99-
if (! $errorLineNumber && isset($entries[$lineNumber - 1])) {
100-
$errorLineNumber = $lineNumber - 1;
101-
continue;
102-
}
10396

104-
if (preg_match($pattern, $line)) {
105-
$errorLineNumber = false;
97+
$errorLineNumber = $lineNumber;
98+
} else {
99+
if (! $errorLineNumber) {
106100
continue;
107101
}
108102

0 commit comments

Comments
 (0)