Skip to content

Commit 6820444

Browse files
committed
be a little more strict when guessing the Laravel log type
1 parent fddafd5 commit 6820444

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/LogTypeRegistrar.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function guessTypeFromFirstLine(LogFile|string $textOrFile): ?string
9494

9595
public function guessTypeFromFileName(LogFile $file): ?string
9696
{
97-
if (str_contains($file->name, 'laravel')) {
97+
if ($this->isPossiblyLaravelLogFile($file->name)) {
9898
return LogType::LARAVEL;
9999
} elseif (str_contains($file->name, 'php-fpm')) {
100100
return LogType::PHP_FPM;
@@ -110,4 +110,10 @@ public function guessTypeFromFileName(LogFile $file): ?string
110110

111111
return null;
112112
}
113+
114+
protected function isPossiblyLaravelLogFile(string $fileName): bool
115+
{
116+
return $fileName === 'laravel.log'
117+
|| preg_match('/laravel-\d{4}-\d{2}-\d{2}\.log/', $fileName);
118+
}
113119
}

0 commit comments

Comments
 (0)