@@ -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('telegram-messenger', $context); |
| 188 | 188 | |
| 189 | - if($logger) { |
|
| 189 | + if ($logger) { |
|
| 190 | 190 | $logger->log($level, $message, $context); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | private function formatMessage($message) { |
| 199 | 199 | |
| 200 | - if($message instanceof \Exception || $message instanceof Error) { |
|
| 200 | + if ($message instanceof \Exception || $message instanceof Error) { |
|
| 201 | 201 | $message = (string) $message; |
| 202 | - } else if(is_array($message) || is_object($message)) { |
|
| 202 | + } else if (is_array($message) || is_object($message)) { |
|
| 203 | 203 | $message = json_encode((array) $message, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
| 204 | 204 | $message = str_replace('\\u0000', '', $message); |
| 205 | 205 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $minDebugLevel = ($_ENV['APP_DEBUG_LEVEL'] ?: LogLevel::DEBUG); |
| 223 | 223 | $minDebugLevel = Logger::toMonologLevel($minDebugLevel); |
| 224 | 224 | |
| 225 | - if($level >= $minDebugLevel) { |
|
| 225 | + if ($level >= $minDebugLevel) { |
|
| 226 | 226 | return true; |
| 227 | 227 | } |
| 228 | 228 | return false; |
@@ -35,15 +35,15 @@ |
||
| 35 | 35 | { |
| 36 | 36 | try { |
| 37 | 37 | $log = new Log(); |
| 38 | - if(is_callable($this->context)) { |
|
| 38 | + if (is_callable($this->context)) { |
|
| 39 | 39 | try { |
| 40 | 40 | $context = call_user_func($this->context, $exception); |
| 41 | - } catch(\Exception $e) { |
|
| 41 | + } catch (\Exception $e) { |
|
| 42 | 42 | self::logInnerException(new \Exception('Can not call ' . $this->context)); |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | $log->critical($exception, (array) $this->context); |
| 46 | - } catch(\Exception $e) { |
|
| 46 | + } catch (\Exception $e) { |
|
| 47 | 47 | self::logInnerException($e); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -11,42 +11,42 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | public static function getInstance($channel, $context) { |
| 13 | 13 | |
| 14 | - if(Registry::hasLogger($channel)) { |
|
| 14 | + if (Registry::hasLogger($channel)) { |
|
| 15 | 15 | return Registry::getInstance($channel); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - if($channel == 'telegram-messenger') { |
|
| 18 | + if ($channel == 'telegram-messenger') { |
|
| 19 | 19 | |
| 20 | 20 | $isEnabled = false; |
| 21 | - if(isset($_ENV['APP_LOG_TELEGRAM'])) { |
|
| 21 | + if (isset($_ENV['APP_LOG_TELEGRAM'])) { |
|
| 22 | 22 | $APP_LOG_TELEGRAM = trim(strtolower($_ENV['APP_LOG_TELEGRAM'])); |
| 23 | - if($APP_LOG_TELEGRAM === 'on' || $APP_LOG_TELEGRAM === 'true' || $APP_LOG_TELEGRAM === '1') { |
|
| 23 | + if ($APP_LOG_TELEGRAM === 'on' || $APP_LOG_TELEGRAM === 'true' || $APP_LOG_TELEGRAM === '1') { |
|
| 24 | 24 | $isEnabled = true; |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - if(!isset($_ENV['APP_LOG_TELEGRAM_KEY']) || empty($_ENV['APP_LOG_TELEGRAM_KEY'])) { |
|
| 28 | + if (!isset($_ENV['APP_LOG_TELEGRAM_KEY']) || empty($_ENV['APP_LOG_TELEGRAM_KEY'])) { |
|
| 29 | 29 | $isEnabled = false; |
| 30 | 30 | } |
| 31 | - if(!isset($_ENV['APP_LOG_TELEGRAM_CHANNEL']) || empty($_ENV['APP_LOG_TELEGRAM_CHANNEL'])) { |
|
| 31 | + if (!isset($_ENV['APP_LOG_TELEGRAM_CHANNEL']) || empty($_ENV['APP_LOG_TELEGRAM_CHANNEL'])) { |
|
| 32 | 32 | $isEnabled = false; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if(!$isEnabled) { |
|
| 35 | + if (!$isEnabled) { |
|
| 36 | 36 | return null; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $sender = new TelegramBotHandler($_ENV['APP_LOG_TELEGRAM_KEY'], $_ENV['APP_LOG_TELEGRAM_CHANNEL']); |
| 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 | } |
| 45 | - if(isset($context['disable_notification']) && $context['disable_notification'] === true) { |
|
| 45 | + if (isset($context['disable_notification']) && $context['disable_notification'] === true) { |
|
| 46 | 46 | $sender->disableNotification(true); |
| 47 | 47 | unset($context['disable_notification']); |
| 48 | 48 | } |
| 49 | - if(isset($context['disable_preview']) && $context['disable_preview'] === true) { |
|
| 49 | + if (isset($context['disable_preview']) && $context['disable_preview'] === true) { |
|
| 50 | 50 | $sender->disableWebPagePreview(true); |
| 51 | 51 | unset($context['disable_preview']); |
| 52 | 52 | } |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | $logPath = $_SERVER['DOCUMENT_ROOT'] . ($_ENV['APP_LOG_FOLDER'] ?: '/log/'); |
| 65 | 65 | $logPath .= $channel . '/' . date('Y-m-d') . '.log'; |
| 66 | 66 | $logDir = pathinfo($logPath, PATHINFO_DIRNAME); |
| 67 | - if(!file_exists($logDir)) { |
|
| 67 | + if (!file_exists($logDir)) { |
|
| 68 | 68 | $mode = 0775; |
| 69 | - if(defined('BX_DIR_PERMISSIONS') && BX_DIR_PERMISSIONS) { |
|
| 69 | + if (defined('BX_DIR_PERMISSIONS') && BX_DIR_PERMISSIONS) { |
|
| 70 | 70 | $mode = BX_DIR_PERMISSIONS; |
| 71 | 71 | } |
| 72 | 72 | mkdir($logDir, $mode, true); |