33namespace Onramplab \LaravelLogEnhancement ;
44
55use Illuminate \Contracts \Foundation \Application ;
6+ use Illuminate \Support \Facades \Facade ;
67use Illuminate \Support \ServiceProvider ;
78use Illuminate \Support \Facades \Route ;
8- use Psr \ Log \ LoggerInterface ;
9+ use Queue ;
910
1011class LaravelLogEnhancementServiceProvider extends ServiceProvider
1112{
@@ -23,6 +24,7 @@ public function boot()
2324 // $this->loadViewsFrom(__DIR__.'/resources/views', 'laravel-log-enhancement');
2425 // $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
2526 // $this->registerRoutes();
27+ $ this ->registerHooks ();
2628 }
2729
2830 /**
@@ -58,16 +60,16 @@ private function routeConfiguration()
5860 */
5961 public function register ()
6062 {
61- // Register facade
62- // $this->app->singleton('laravel-log-enhancement', function () {
63- // return new LaravelLogEnhancement;
64- // });
65- $ this ->app ->singleton (Logger::class, function (Application $ app ) {
66- return new Logger ($ app ->make (LoggerInterface::class));
63+ $ this ->app ->singleton ('laravel-log-enhancement-logger ' , function (Application $ app ) {
64+ return new LogManager ($ app );
6765 });
66+ }
6867
69- $ this ->app ->singleton ('laravel-log-enhancement-logger ' , function ($ app ) {
70- return new LogManager ($ app );
68+ public function registerHooks ()
69+ {
70+ Queue::before (function () {
71+ $ this ->app ->forgetInstance ('laravel-log-enhancement-logger ' );
72+ Facade::clearResolvedInstance ('laravel-log-enhancement-logger ' );
7173 });
7274 }
7375
0 commit comments