/** * Register the service provider. * * @return void */ public function register() { $this->mergeConfigFrom(__DIR__ . '/../config/profiler.php', 'profiler'); if (!$this->app->bound('hash')) { $hash = $this->app->share(function () { return new BcryptHasher(); }); $this->app->bind('hash', $hash); } $config = $this->app->make('config'); $enable = $config->get('app.debug'); $enable = boolval($enable); $profilerRequest = $this->isProfilerCall(); /** @var Logger $logger */ $logger = $this->app->make('log'); try { $profiler = ProfilerFactory::build($this->buildConfiguration($enable, $profilerRequest)); } catch (\Exception $e) { $logger->error('Fail to build profiler error: ' . $e->getMessage(), [' message : ' => $e->getMessage(), ' file : ' => $e->getFile(), ' line : ' => $e->getLine(), ' trace : ' => $e->getTraceAsString()]); $profiler = new NullProfiler(); } if ($enable) { if (!$profilerRequest) { $logger->getMonolog()->pushHandler($profiler->getLogger()); } $this->registerCors(); $this->registerRoutes(); } $this->registerProfiler($profiler); $profiler->initiate(); $profiler->getContext()->sendDebugIds(); Event::listen('kernel.handled', function () use($profiler) { $profiler->terminate(); }); }
public function testMagicCall() { $this->profiler->start('foo', 'BAR'); $this->profiler->stop('foo'); $this->profiler->error('No beer'); }