@@ -14,41 +14,41 @@ discard block |
||
| 14 | 14 | public static function getInstance($channel, $context) { |
| 15 | 15 | |
| 16 | 16 | $key = md5(json_encode([$channel, $context])); |
| 17 | - if(Registry::hasLogger($key)) { |
|
| 17 | + if (Registry::hasLogger($key)) { |
|
| 18 | 18 | return Registry::getInstance($key); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - if($channel == self::TELEGRAM_CHANNEL) { |
|
| 21 | + if ($channel == self::TELEGRAM_CHANNEL) { |
|
| 22 | 22 | |
| 23 | - if(isset($_ENV['APP_LOG_TELEGRAM'])) { |
|
| 23 | + if (isset($_ENV['APP_LOG_TELEGRAM'])) { |
|
| 24 | 24 | $APP_LOG_TELEGRAM = trim(strtolower($_ENV['APP_LOG_TELEGRAM'])); |
| 25 | - if($APP_LOG_TELEGRAM !== 'on' && $APP_LOG_TELEGRAM !== 'true' && $APP_LOG_TELEGRAM !== '1') { |
|
| 25 | + if ($APP_LOG_TELEGRAM !== 'on' && $APP_LOG_TELEGRAM !== 'true' && $APP_LOG_TELEGRAM !== '1') { |
|
| 26 | 26 | return null; |
| 27 | 27 | } |
| 28 | 28 | } else { |
| 29 | 29 | return null; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if(!isset($_ENV['APP_LOG_TELEGRAM_KEY']) || empty($_ENV['APP_LOG_TELEGRAM_KEY'])) { |
|
| 32 | + if (!isset($_ENV['APP_LOG_TELEGRAM_KEY']) || empty($_ENV['APP_LOG_TELEGRAM_KEY'])) { |
|
| 33 | 33 | return null; |
| 34 | 34 | } |
| 35 | - if(!isset($_ENV['APP_LOG_TELEGRAM_CHATID']) || empty($_ENV['APP_LOG_TELEGRAM_CHATID'])) { |
|
| 35 | + if (!isset($_ENV['APP_LOG_TELEGRAM_CHATID']) || empty($_ENV['APP_LOG_TELEGRAM_CHATID'])) { |
|
| 36 | 36 | return null; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $sender = new TelegramBotHandler($_ENV['APP_LOG_TELEGRAM_KEY'], $_ENV['APP_LOG_TELEGRAM_CHATID']); |
| 40 | 40 | |
| 41 | - if(isset($context['parse_mode']) && !empty($context['parse_mode'])) { |
|
| 41 | + if (isset($context['parse_mode']) && !empty($context['parse_mode'])) { |
|
| 42 | 42 | $sender->setParseMode($context['parse_mode']); |
| 43 | 43 | unset($context['parse_mode']); |
| 44 | 44 | } else { |
| 45 | 45 | $sender->setParseMode('HTML'); |
| 46 | 46 | } |
| 47 | - if(isset($context['disable_notification']) && $context['disable_notification'] === true) { |
|
| 47 | + if (isset($context['disable_notification']) && $context['disable_notification'] === true) { |
|
| 48 | 48 | $sender->disableNotification(true); |
| 49 | 49 | unset($context['disable_notification']); |
| 50 | 50 | } |
| 51 | - if(isset($context['disable_preview']) && $context['disable_preview'] === false) { |
|
| 51 | + if (isset($context['disable_preview']) && $context['disable_preview'] === false) { |
|
| 52 | 52 | $sender->disableWebPagePreview(false); |
| 53 | 53 | unset($context['disable_preview']); |
| 54 | 54 | } else { |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | $logPath = $_SERVER['DOCUMENT_ROOT'] . ($_ENV['APP_LOG_FOLDER'] ?: '/log/'); |
| 69 | 69 | $logPath .= $channel . '/' . date('Y-m-d') . '.log'; |
| 70 | 70 | $logDir = pathinfo($logPath, PATHINFO_DIRNAME); |
| 71 | - if(!file_exists($logDir)) { |
|
| 71 | + if (!file_exists($logDir)) { |
|
| 72 | 72 | $mode = 0775; |
| 73 | - if(defined('BX_DIR_PERMISSIONS') && BX_DIR_PERMISSIONS) { |
|
| 73 | + if (defined('BX_DIR_PERMISSIONS') && BX_DIR_PERMISSIONS) { |
|
| 74 | 74 | $mode = BX_DIR_PERMISSIONS; |
| 75 | 75 | } |
| 76 | 76 | mkdir($logDir, $mode, true); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function __construct($channel = '') { |
| 19 | 19 | |
| 20 | - if(!empty($channel)) { |
|
| 20 | + if (!empty($channel)) { |
|
| 21 | 21 | $this->channel = $channel; |
| 22 | 22 | } else { |
| 23 | 23 | $this->channel = ($_ENV['APP_LOG_BITRIX_CHANNEL'] ?: 'bitrix'); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | $logger = LoggerFactory::getInstance(LoggerFactory::TELEGRAM_CHANNEL, $context); |
| 188 | 188 | |
| 189 | - if($logger) { |
|
| 189 | + if ($logger) { |
|
| 190 | 190 | $message = FormatHelper::stringfyTelegramMessage($message, (array) $context); |
| 191 | 191 | $logger->log($level, $message, $context); |
| 192 | 192 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $minDebugLevel = ($_ENV['APP_DEBUG_LEVEL'] ?: LogLevel::DEBUG); |
| 208 | 208 | $minDebugLevel = Logger::toMonologLevel($minDebugLevel); |
| 209 | 209 | |
| 210 | - if($level >= $minDebugLevel) { |
|
| 210 | + if ($level >= $minDebugLevel) { |
|
| 211 | 211 | return true; |
| 212 | 212 | } |
| 213 | 213 | return false; |