mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-18 15:18:08 +02:00
Include record message/context/extra data when throwing an exception because the log cannot be opened, fixes #1630
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
||||
|
||||
use RuntimeException;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Handler send logs to Telegram using Telegram Bot API.
|
||||
@@ -247,12 +248,12 @@ class TelegramBotHandler extends AbstractProcessingHandler
|
||||
|
||||
$result = Curl\Util::execute($ch);
|
||||
if (!is_string($result)) {
|
||||
throw new RuntimeException('Telegram API error. Description: No response');
|
||||
throw new RuntimeException('Telegram API error. Description: No response' . Utils::getRecordMessageForException($record));
|
||||
}
|
||||
$result = json_decode($result, true);
|
||||
|
||||
if ($result['ok'] === false) {
|
||||
throw new RuntimeException('Telegram API error. Description: ' . $result['description']);
|
||||
throw new RuntimeException('Telegram API error. Description: ' . $result['description'] . Utils::getRecordMessageForException($record));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +266,7 @@ class TelegramBotHandler extends AbstractProcessingHandler
|
||||
{
|
||||
$truncatedMarker = ' (...truncated)';
|
||||
if (!$this->splitLongMessages && strlen($message) > self::MAX_MESSAGE_LENGTH) {
|
||||
return [substr($message, 0, self::MAX_MESSAGE_LENGTH - strlen($truncatedMarker)) . $truncatedMarker];
|
||||
return [Utils::substr($message, 0, self::MAX_MESSAGE_LENGTH - strlen($truncatedMarker)) . $truncatedMarker];
|
||||
}
|
||||
|
||||
return str_split($message, self::MAX_MESSAGE_LENGTH);
|
||||
|
Reference in New Issue
Block a user