@@ -10,11 +10,11 @@ |
||
| 10 | 10 | /** |
| 11 | 11 | * @var Logger |
| 12 | 12 | */ |
| 13 | - protected $logger; |
|
| 14 | - /** |
|
| 13 | + protected $logger; |
|
| 14 | + /** |
|
| 15 | 15 | * @var callable |
| 16 | 16 | */ |
| 17 | - protected $context; |
|
| 17 | + protected $context; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * {@inheritdoc} |
@@ -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 | } |
@@ -5,17 +5,17 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class ArrayFormatter extends NormalizerFormatter |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * {@inheritdoc} |
|
| 10 | - */ |
|
| 11 | - public function format(array $record) |
|
| 12 | - { |
|
| 13 | - /** @var \DateTime $date */ |
|
| 14 | - $date = $record['datetime']; |
|
| 15 | - $output = array(sprintf("%s %s", $record['level_name'], $date->format("d.m.Y H:i:s"))); |
|
| 8 | + /** |
|
| 9 | + * {@inheritdoc} |
|
| 10 | + */ |
|
| 11 | + public function format(array $record) |
|
| 12 | + { |
|
| 13 | + /** @var \DateTime $date */ |
|
| 14 | + $date = $record['datetime']; |
|
| 15 | + $output = array(sprintf("%s %s", $record['level_name'], $date->format("d.m.Y H:i:s"))); |
|
| 16 | 16 | $output[] = $record['message']; |
| 17 | - if(is_array($record['context'])) { |
|
| 18 | - if(count($record['context']) == 1) { |
|
| 17 | + if(is_array($record['context'])) { |
|
| 18 | + if(count($record['context']) == 1) { |
|
| 19 | 19 | $output[] = current($record['context']); |
| 20 | 20 | } else if(count($record['context']) > 1) { |
| 21 | 21 | $output[] = print_r($record['context'], true); |
@@ -24,6 +24,6 @@ discard block |
||
| 24 | 24 | $output[] = $record['context']; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - return join("\r\n", $output) . "\r\n------------------------------------------------------------------------\r\n"; |
|
| 28 | - } |
|
| 27 | + return join("\r\n", $output) . "\r\n------------------------------------------------------------------------\r\n"; |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -14,13 +14,13 @@ |
||
| 14 | 14 | $date = $record['datetime']; |
| 15 | 15 | $output = array(sprintf("%s %s", $record['level_name'], $date->format("d.m.Y H:i:s"))); |
| 16 | 16 | $output[] = $record['message']; |
| 17 | - if(is_array($record['context'])) { |
|
| 18 | - if(count($record['context']) == 1) { |
|
| 17 | + if (is_array($record['context'])) { |
|
| 18 | + if (count($record['context']) == 1) { |
|
| 19 | 19 | $output[] = current($record['context']); |
| 20 | - } else if(count($record['context']) > 1) { |
|
| 20 | + } else if (count($record['context']) > 1) { |
|
| 21 | 21 | $output[] = print_r($record['context'], true); |
| 22 | 22 | } |
| 23 | - } else if(!empty($record['context'])) { |
|
| 23 | + } else if (!empty($record['context'])) { |
|
| 24 | 24 | $output[] = $record['context']; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | define("NO_KEEP_STATISTIC", "Y"); |
| 3 | -define("NO_AGENT_STATISTIC","Y"); |
|
| 4 | -require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php'); |
|
| 3 | +define("NO_AGENT_STATISTIC", "Y"); |
|
| 4 | +require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php'); |
|
| 5 | 5 | |
| 6 | 6 | $log = new \App\Log('test'); |
| 7 | 7 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | try { |
| 15 | 15 | throw new Exception('test exception'); |
| 16 | -} catch(Exception $e) { |
|
| 16 | +} catch (Exception $e) { |
|
| 17 | 17 | $log->error($e); |
| 18 | 18 | } |
| 19 | 19 | throw new Exception('test exception'); |
@@ -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; |
@@ -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); |