diff --git a/src/PerformanceServiceProvider.php b/src/PerformanceServiceProvider.php index b1da0b3..6baf86f 100644 --- a/src/PerformanceServiceProvider.php +++ b/src/PerformanceServiceProvider.php @@ -11,14 +11,21 @@ class PerformanceServiceProvider extends ServiceProvider { public function boot() + { + $this->publishes([ + __DIR__ . '/ressources/performance.php' => config_path('performance.php'), + ]); + } + + public function register() { $dispatcher = $this->app->make(Dispatcher::class); - $this->app->singleton(QueryContainer::class, function($app) { + $this->app->singleton(QueryContainer::class, function ($app) { return new QueryContainer($app->make(Request::class), $app->make(Filesystem::class)); }); - $dispatcher->listen(QueryExecuted::class, function(QueryExecuted $event) { + $dispatcher->listen(QueryExecuted::class, function (QueryExecuted $event) { $container = $this->app->make(QueryContainer::class); $container->addByEvent($event); }); diff --git a/src/QueryContainer.php b/src/QueryContainer.php index e79962a..b3e13c0 100644 --- a/src/QueryContainer.php +++ b/src/QueryContainer.php @@ -41,7 +41,7 @@ class QueryContainer public function __construct(Request $request = null, Filesystem $filesystem) { $this->resetCounters(); - $this->slowQueryThreshold = 10; + $this->slowQueryThreshold = config('performance.slow_query_threshold', 100); $this->timestamp = Carbon::now(); $this->url = $request->getPathInfo(); $this->method = $request->getMethod(); diff --git a/src/ressources/performance.php b/src/ressources/performance.php new file mode 100644 index 0000000..ecc1c0e --- /dev/null +++ b/src/ressources/performance.php @@ -0,0 +1,5 @@ + 10 +]; \ No newline at end of file