Passed
Push — master ( 0bef7d...307b32 )
by Ioannes
02:01
created
src/Log.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     public function __construct($channel = null) {
22 22
 
23 23
         $this->minDebugLevel = ($_ENV['APP_DEBUG_LEVEL'] ?: 'DEBUG');
24
-        if($channel) {
24
+        if ($channel) {
25 25
             $this->channel = $channel;
26 26
             //TODO: get channel options
27 27
         } else {
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
      */
193 193
     private function formatMessage($message) {
194 194
 
195
-        if($message instanceof \Exception || $message instanceof Error) {
195
+        if ($message instanceof \Exception || $message instanceof Error) {
196 196
             $message = (string) $message;
197
-        } else if(is_array($message) || is_object($message)) {
197
+        } else if (is_array($message) || is_object($message)) {
198 198
             $message = json_encode((array) $message, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
199 199
             $message = str_replace('\\u0000', '', $message);
200 200
         }
@@ -206,15 +206,15 @@  discard block
 block discarded – undo
206 206
      */
207 207
     public function getLogger() {
208 208
 
209
-        if(Registry::hasLogger($this->channel)) {
209
+        if (Registry::hasLogger($this->channel)) {
210 210
             return Registry::getInstance($this->channel);
211 211
         }
212 212
         $logPath = $_SERVER['DOCUMENT_ROOT'] . ($_ENV['APP_LOG_FOLDER'] ?: '/log/');
213 213
         $logPath .= $this->channel . '/' . date('Y-m-d') . '.log';
214 214
         $logDir = pathinfo($logPath, PATHINFO_DIRNAME);
215
-        if(!file_exists($logDir)) {
215
+        if (!file_exists($logDir)) {
216 216
             $mode = 0775;
217
-            if(defined('BX_DIR_PERMISSIONS') && BX_DIR_PERMISSIONS) {
217
+            if (defined('BX_DIR_PERMISSIONS') && BX_DIR_PERMISSIONS) {
218 218
                 $mode = BX_DIR_PERMISSIONS;
219 219
             }
220 220
             mkdir($logDir, $mode, true);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
         $handler->setFormatter(new ArrayFormatter());
225 225
 
226 226
         $logger = new Logger($this->channel);
227
-        if($handler) $logger->pushHandler($handler);
227
+        if ($handler) $logger->pushHandler($handler);
228 228
         Registry::addLogger($logger, $this->channel, true);
229 229
 
230 230
         return $logger;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
         $levels = Logger::getLevels();
239 239
 
240
-        if($this->minDebugLevel && isset($levels[$this->minDebugLevel])) {
240
+        if ($this->minDebugLevel && isset($levels[$this->minDebugLevel])) {
241 241
             return $levels[$this->minDebugLevel];
242 242
         } else {
243 243
             return Logger::DEBUG;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
             return true;
255 255
         }
256 256
         $min_level = self::getMinErrorLevel();
257
-        if($level >= $min_level) {
257
+        if ($level >= $min_level) {
258 258
             return true;
259 259
         }
260 260
         return false;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -224,7 +224,9 @@
 block discarded – undo
224 224
         $handler->setFormatter(new ArrayFormatter());
225 225
 
226 226
         $logger = new Logger($this->channel);
227
-        if($handler) $logger->pushHandler($handler);
227
+        if($handler) {
228
+            $logger->pushHandler($handler);
229
+        }
228 230
         Registry::addLogger($logger, $this->channel, true);
229 231
 
230 232
         return $logger;
Please login to merge, or discard this patch.
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   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,15 +34,15 @@
 block discarded – undo
34 34
     {
35 35
         try {
36 36
             $log = new Log();
37
-            if(is_callable($this->context)) {
37
+            if (is_callable($this->context)) {
38 38
                 try {
39 39
                     $context = call_user_func($this->context, $exception);
40
-                } catch(\Exception $e) {
40
+                } catch (\Exception $e) {
41 41
                     $log->logInnerException(new \Exception('Can not call ' . $this->context));
42 42
                 }
43 43
             }
44 44
             $log->critical($exception, (array) $this->context);
45
-        } catch(\Exception $e) {
45
+        } catch (\Exception $e) {
46 46
             $log->logInnerException($e);
47 47
         }
48 48
     }
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.