Skip to content

Commit

Permalink
check Telegram class & Bitrix debug
Browse files Browse the repository at this point in the history
  • Loading branch information
itrukhin committed Feb 8, 2023
1 parent 08545ad commit 6734987
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ private function isDebugEnabled($level)
*/
protected function logInnerException(\Exception $exception)
{
Debug::writeToFile((string) $exception, "", "inner_error.log");
if(class_exists('\Bitrix\Main\Diag\Debug')) {
Debug::writeToFile((string) $exception, "", "monolog_error.log");
} else {
$logPath = $_SERVER['DOCUMENT_ROOT'] . ($_ENV['APP_LOG_FOLDER'] ?: '/log/');
$logPath = rtrim($logPath, "/");
file_put_contents($logPath . '/monolog_error.log', (string) $exception);
}
}

public static function cleanLogs($daysAgo = 15) {
Expand Down
4 changes: 4 additions & 0 deletions src/Monolog/LoggerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public static function getInstance($channel, $context) {
return null;
}

if(!class_exists('\Monolog\Handler\TelegramBotHandler')) {
return null;
}

$sender = new TelegramBotHandler($_ENV['APP_LOG_TELEGRAM_KEY'], $_ENV['APP_LOG_TELEGRAM_CHATID']);

if(isset($context['parse_mode']) && !empty($context['parse_mode'])) {
Expand Down

0 comments on commit 6734987

Please sign in to comment.