Skip to content

Commit

Permalink
Merge pull request #377 from opcodesio/bug/fix-laravel-log-guessing
Browse files Browse the repository at this point in the history
be a little more strict when guessing the Laravel log type
  • Loading branch information
arukompas authored May 20, 2024
2 parents fddafd5 + 6820444 commit d0d1e94
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/LogTypeRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function guessTypeFromFirstLine(LogFile|string $textOrFile): ?string

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

return null;
}

protected function isPossiblyLaravelLogFile(string $fileName): bool
{
return $fileName === 'laravel.log'
|| preg_match('/laravel-\d{4}-\d{2}-\d{2}\.log/', $fileName);
}
}

0 comments on commit d0d1e94

Please sign in to comment.