Skip to content

Commit

Permalink
fix for lumen
Browse files Browse the repository at this point in the history
  • Loading branch information
grkamil committed Oct 26, 2021
1 parent 7e2cba3 commit 94e1635
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ config(['telegram-logger.template'=>'laravel-telegram-logging::custom'])
'driver' => 'custom',
'via' => TelegramLogger::class,
'chat_id' => env('TELEGRAM_COMPANY_CHAT_ID'),
'token' => env('TELEGRAM_COMPANY_BOT_TOKEN')
'token' => env('TELEGRAM_COMPANY_BOT_TOKEN'),
'level' => 'debug'
],

'operations' => [
'driver' => 'custom',
'via' => TelegramLogger::class,
'chat_id' => env('TELEGRAM_OPERATIONS_CHAT_ID'),
'token' => env('TELEGRAM_OPERATIONS_BOT_TOKEN')
'token' => env('TELEGRAM_OPERATIONS_BOT_TOKEN'),
'level' => 'debug'
]
]
]
Expand All @@ -118,7 +120,11 @@ return [
'token' => env('TELEGRAM_LOGGER_BOT_TOKEN'),

// Telegram chat id
'chat_id' => env('TELEGRAM_LOGGER_CHAT_ID')
'chat_id' => env('TELEGRAM_LOGGER_CHAT_ID'),

// you can define your custom template for message
// e.g: logging.template
// 'template' => 'some your view path'
];
```

Expand Down
14 changes: 9 additions & 5 deletions src/TelegramHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,15 @@ protected function getDefaultFormatter(): FormatterInterface
*/
private function formatText(array $record): string
{
return view(config('telegram-logger.template'), array_merge($record,[
'appName' => $this->appName,
'appEnv' => $this->appEnv,
])
);
if ($template = config('telegram-logger.template')) {
return view($template, array_merge($record, [
'appName' => $this->appName,
'appEnv' => $this->appEnv,
])
);
}

return sprintf("<b>%s</b> (%s)\n%s", $this->appName, $record['level_name'], $record['formatted']);
}

/**
Expand Down

0 comments on commit 94e1635

Please sign in to comment.