فهرست منبع

Extend debug mode

Messages with status 400+ can be logged.
Visman 2 سال پیش
والد
کامیت
0dc8a80645
4فایلهای تغییر یافته به همراه14 افزوده شده و 3 حذف شده
  1. 1 1
      app/Models/Pages/Debug.php
  2. 11 0
      app/Models/Pages/Message.php
  3. 1 1
      app/bootstrap.php
  4. 1 1
      app/config/main.dist.php

+ 1 - 1
app/Models/Pages/Debug.php

@@ -23,7 +23,7 @@ class Debug extends Page
             $this->numQueries = $this->c->DB->getCount();
 
             if (
-                $this->c->DEBUG > 1
+                2 & $this->c->DEBUG
                 && $this->user->isAdmin
             ) {
                 $total   = 0;

+ 11 - 0
app/Models/Pages/Message.php

@@ -52,6 +52,17 @@ class Message extends Page
 
         if ('' !== $message) {
             $this->fIswev = [$type, $message];
+
+            if (
+                $status > 399
+                && 4 & $this->c->DEBUG
+            ) {
+                $this->c->Log->debug("Status {$status}: {$_SERVER['REQUEST_URI']}", [
+                    'user'    => $this->user->fLog(),
+                    'message' => $message,
+                    'headers' => true,
+                ]);
+            }
         }
 
         return $this;

+ 1 - 1
app/bootstrap.php

@@ -87,7 +87,7 @@ if (
 
 if (
     null !== $tpl
-    && $c->DEBUG > 0
+    && 3 & $c->DEBUG
 ) {
     $debug = \rtrim($c->View->rendering($c->Debug->debug()));
     $tpl   = \str_replace('<!-- debuginfo -->', $debug, $tpl);

+ 1 - 1
app/config/main.dist.php

@@ -35,7 +35,7 @@ return [
         'algo' => 'sha1',
         'salt' => '_SALT_FOR_HMAC_',
     ],
-    'DEBUG'            => 0,
+    'DEBUG'            => 0, // 1st&2nd: time/memory, 2nd: queries, 3rd: message 400+ to log
     'MAINTENANCE_OFF'  => false,
     'BBCODE_INFO'      => [
         'smTpl'    => '<img src="{url}" alt="{alt}">',