Passed
Push — master ( 5322f3...e11f3e )
by Ioannes
01:31
created
src/Monolog/ExceptionHandlerLog.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@
 block discarded – undo
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}
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,20 +35,20 @@
 block discarded – undo
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
-            if(!is_array($this->context)) {
45
+            if (!is_array($this->context)) {
46 46
                 $this->context = (!empty($this->context) ? [$this->context] : []);
47 47
             }
48 48
             $this->context['source'] = self::logTypeToString($logType);
49 49
             $log->telegram(LogLevel::CRITICAL, $exception, $this->context);
50 50
 
51
-        } catch(\Exception $e) {
51
+        } catch (\Exception $e) {
52 52
             self::logInnerException($e);
53 53
         }
54 54
     }
Please login to merge, or discard this patch.
src/Monolog/ArrayFormatter.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,17 +5,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
examples/log_test.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
src/Monolog/FormatHelper.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
      */
10 10
     public static function stringfyMessage($message) {
11 11
 
12
-        if($message instanceof \Throwable) {
12
+        if ($message instanceof \Throwable) {
13 13
             $message = (string) $message;
14
-        } else if(is_array($message) || is_object($message)) {
14
+        } else if (is_array($message) || is_object($message)) {
15 15
             $message = json_encode((array) $message, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
16 16
             $message = str_replace('\\u0000', '', $message);
17 17
         }
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
 
28 28
         $source = (isset($context['source']) ? sprintf("<b>%s</b>", (string) $context['source']) : '');
29 29
 
30
-        if($message instanceof \Throwable) {
30
+        if ($message instanceof \Throwable) {
31 31
 
32 32
             $message = sprintf("%s, <i>File: %s</i>", $message->getMessage(), $message->getFile());
33 33
 
34
-        } else if(is_array($message) || is_object($message)) {
34
+        } else if (is_array($message) || is_object($message)) {
35 35
 
36 36
             $message = json_encode((array) $message, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
37 37
             $message = str_replace('\\u0000', '', $message);
38
-            if(strlen($message) > 4000) {
38
+            if (strlen($message) > 4000) {
39 39
                 $message = substr($message, 0, 4000) . '...';
40 40
             }
41 41
             $message = sprintf("<code>%s</code>", $message);
42 42
         }
43 43
 
44
-        if(!empty($source)) {
44
+        if (!empty($source)) {
45 45
             return sprintf("%s: %s", $source, $message);
46 46
         } else {
47 47
             return $message;
Please login to merge, or discard this patch.
src/Monolog/LoggerFactory.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,41 +14,41 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Log.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.