File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ TELEGRAM_BOT_TOKEN=your-telegram-bot-token
3131TELEGRAM_CHAT_ID=your-telegram-chat-id
3232```
3333
34- 3 . Configure logging in ` config/telegram-logger .php ` :
34+ 3 . Configure logging in ` config/logging .php ` :
3535
3636``` php
3737'channels' => [
Original file line number Diff line number Diff line change 33namespace C0deM1ner \LaravelTelegramLogger \Providers ;
44
55use C0deM1ner \LaravelTelegramLogger \Console \Commands \SendTestMessageCommand ;
6+ use Illuminate \Contracts \Debug \ExceptionHandler ;
67use Illuminate \Support \ServiceProvider ;
8+ use Throwable ;
79
810class TelegramLoggerServiceProvider extends ServiceProvider
911{
1012 /**
1113 * Register any application services.
1214 *
1315 * @return void
16+ * @throws Throwable
1417 */
1518 public function register (): void
1619 {
17- //
20+ $ errorCodes = config ('telegram-logger.log_errors ' );
21+
22+ if (count ($ errorCodes ) > 0 && !$ this ->app ->runningInConsole ()) {
23+ app (ExceptionHandler::class)->reportable (function (Throwable $ e ) use ($ errorCodes ) {
24+ if (method_exists ($ e , 'getStatusCode ' )) {
25+ $ code = $ e ->getStatusCode ();
26+
27+ } else {
28+ $ code = 500 ;
29+ }
30+
31+
32+ if (in_array ($ code , $ errorCodes )) {
33+ telegramLog ()->error ($ e ->getMessage ());
34+ }
35+ });
36+ }
1837 }
1938
2039 /**
You can’t perform that action at this time.
0 commit comments