|
3 | 3 | namespace Honeybadger\HoneybadgerLaravel; |
4 | 4 |
|
5 | 5 | use GuzzleHttp\Client; |
| 6 | +use Honeybadger\LogHandler; |
| 7 | +use Honeybadger\Honeybadger; |
6 | 8 | use Honeybadger\Contracts\Reporter; |
7 | 9 | use Honeybadger\Exceptions\ServiceException; |
8 | | -use Honeybadger\Honeybadger; |
9 | 10 | use Honeybadger\HoneybadgerLaravel\Commands\HoneybadgerCheckinCommand; |
10 | 11 | use Honeybadger\HoneybadgerLaravel\Commands\HoneybadgerDeployCommand; |
11 | 12 | use Honeybadger\HoneybadgerLaravel\Commands\HoneybadgerInstallCommand; |
@@ -44,23 +45,10 @@ public function register() |
44 | 45 | { |
45 | 46 | $this->mergeConfigFrom(__DIR__.'/../config/honeybadger.php', 'honeybadger'); |
46 | 47 |
|
47 | | - $this->app->singleton(Reporter::class, function ($app) { |
48 | | - return HoneybadgerLaravel::make($app['config']['honeybadger']); |
49 | | - }); |
50 | | - |
51 | | - $this->app->alias(Reporter::class, Honeybadger::class); |
52 | | - $this->app->alias(Reporter::class, 'honeybadger'); |
53 | | - |
54 | | - // In some cases (like the test command), we definitely want to throw any errors |
55 | | - // Laravel's contextual binding doesn't support method injection, |
56 | | - // so the handle() method will have to request this client specifically. |
57 | | - $this->app->singleton('honeybadger.loud', function ($app) { |
58 | | - $config = $app['config']['honeybadger']; |
59 | | - $config['service_exception_handler'] = function (ServiceException $e) { |
60 | | - throw $e; |
61 | | - }; |
| 48 | + $this->registerReporters(); |
62 | 49 |
|
63 | | - return HoneybadgerLaravel::make($config); |
| 50 | + $this->app->bind(LogHandler::class, function ($app) { |
| 51 | + return new LogHandler($app[Reporter::class]); |
64 | 52 | }); |
65 | 53 |
|
66 | 54 | $this->app->singleton('honeybadger.isLumen', function () { |
@@ -185,4 +173,26 @@ protected function setUpAutomaticBreadcrumbs() |
185 | 173 | (new $breadcrumb)->register(); |
186 | 174 | } |
187 | 175 | } |
| 176 | + |
| 177 | + protected function registerReporters(): void |
| 178 | + { |
| 179 | + $this->app->singleton(Reporter::class, function ($app) { |
| 180 | + return HoneybadgerLaravel::make($app['config']['honeybadger']); |
| 181 | + }); |
| 182 | + |
| 183 | + $this->app->alias(Reporter::class, Honeybadger::class); |
| 184 | + $this->app->alias(Reporter::class, 'honeybadger'); |
| 185 | + |
| 186 | + // In some cases (like the test command), we definitely want to throw any errors |
| 187 | + // Laravel's contextual binding doesn't support method injection, |
| 188 | + // so the handle() method will have to request this client specifically. |
| 189 | + $this->app->singleton('honeybadger.loud', function ($app) { |
| 190 | + $config = $app['config']['honeybadger']; |
| 191 | + $config['service_exception_handler'] = function (ServiceException $e) { |
| 192 | + throw $e; |
| 193 | + }; |
| 194 | + |
| 195 | + return HoneybadgerLaravel::make($config); |
| 196 | + }); |
| 197 | + } |
188 | 198 | } |
0 commit comments