Skip to content

Commit 94e1635

Browse files
committed
fix for lumen
1 parent 7e2cba3 commit 94e1635

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ config(['telegram-logger.template'=>'laravel-telegram-logging::custom'])
9090
'driver' => 'custom',
9191
'via' => TelegramLogger::class,
9292
'chat_id' => env('TELEGRAM_COMPANY_CHAT_ID'),
93-
'token' => env('TELEGRAM_COMPANY_BOT_TOKEN')
93+
'token' => env('TELEGRAM_COMPANY_BOT_TOKEN'),
94+
'level' => 'debug'
9495
],
9596

9697
'operations' => [
9798
'driver' => 'custom',
9899
'via' => TelegramLogger::class,
99100
'chat_id' => env('TELEGRAM_OPERATIONS_CHAT_ID'),
100-
'token' => env('TELEGRAM_OPERATIONS_BOT_TOKEN')
101+
'token' => env('TELEGRAM_OPERATIONS_BOT_TOKEN'),
102+
'level' => 'debug'
101103
]
102104
]
103105
]
@@ -118,7 +120,11 @@ return [
118120
'token' => env('TELEGRAM_LOGGER_BOT_TOKEN'),
119121

120122
// Telegram chat id
121-
'chat_id' => env('TELEGRAM_LOGGER_CHAT_ID')
123+
'chat_id' => env('TELEGRAM_LOGGER_CHAT_ID'),
124+
125+
// you can define your custom template for message
126+
// e.g: logging.template
127+
// 'template' => 'some your view path'
122128
];
123129
```
124130

src/TelegramHandler.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,15 @@ protected function getDefaultFormatter(): FormatterInterface
104104
*/
105105
private function formatText(array $record): string
106106
{
107-
return view(config('telegram-logger.template'), array_merge($record,[
108-
'appName' => $this->appName,
109-
'appEnv' => $this->appEnv,
110-
])
111-
);
107+
if ($template = config('telegram-logger.template')) {
108+
return view($template, array_merge($record, [
109+
'appName' => $this->appName,
110+
'appEnv' => $this->appEnv,
111+
])
112+
);
113+
}
114+
115+
return sprintf("<b>%s</b> (%s)\n%s", $this->appName, $record['level_name'], $record['formatted']);
112116
}
113117

114118
/**

0 commit comments

Comments
 (0)