Skip to content

Commit

Permalink
refactor(logging): replace NullLogger with ConsoleLogger for verbose …
Browse files Browse the repository at this point in the history
…output

This commit enhances the logging mechanism by introducing ConsoleLogger for verbose
output in the AppServiceProvider. The change allows for more detailed logging in
the console while maintaining the option to use a NullLogger for non-verbose environments.
The implementation ensures compatibility with existing configurations by only
using ConsoleLogger when the current logger is not a NullLogger.

- Added ConsoleLogger import to the AppServiceProvider
- Modified the logger extension to conditionally return a ConsoleLogger
- Preserves existing behavior for non-console or non-verbose contexts
  • Loading branch information
[email protected] committed Oct 13, 2024
1 parent dd6cd69 commit c71c626
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\ConsoleOutput;

final class AppServiceProvider extends ServiceProvider
Expand Down Expand Up @@ -63,6 +64,7 @@ public function boot(): void
$_SERVER['VAR_DUMPER_FORMAT'] = 'server';

$this->app->extend(LoggerInterface::class, static function (LoggerInterface $logger): NullLogger {
// return $logger instanceof ConsoleLogger ? $logger : new ConsoleLogger(app(OutputStyle::class));
return $logger instanceof NullLogger ? $logger : new NullLogger();
});

Expand Down

0 comments on commit c71c626

Please sign in to comment.