]> git.mxchange.org Git - friendica.git/commitdiff
Exclude classes from logging
authorMichael <heluecht@pirati.ca>
Sun, 15 Oct 2023 19:45:32 +0000 (19:45 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 15 Oct 2023 19:45:32 +0000 (19:45 +0000)
src/Core/Logger/Util/Introspection.php
src/Core/System.php

index c154eec9f58729aace72bcd7516e72f82c27f211..3b7d807f52ff2be83b709b202f3b908ea868cbc8 100644 (file)
@@ -87,7 +87,7 @@ class Introspection implements IHaveCallIntrospections
                        'line'       => $trace[$i - 1]['line'] ?? null,
                        'function'   => $trace[$i]['function'] ?? null,
                        'request-id' => $this->requestId,
-                       'stack'      => System::callstack(10, 4),
+                       'stack'      => System::callstack(10, 0, true, ['Friendica\Core\Logger\Type\StreamLogger', 'Friendica\Core\Logger\Type\AbstractLogger', 'Friendica\Core\Logger\Type\WorkerLogger', 'Friendica\Core\Logger']),
                ];
        }
 
index 197e7b2ae6acd43af9785bf490bf4531e2e08b87..a51ffe0d1fda91fdfa9f83b6b2289e8f1d57e319 100644 (file)
@@ -226,13 +226,14 @@ class System
        /**
         * Returns a string with a callstack. Can be used for logging.
         *
-        * @param integer $depth  How many calls to include in the stacks after filtering
-        * @param int     $offset How many calls to shave off the top of the stack, for example if
-        *                        this is called from a centralized method that isn't relevant to the callstack
-        * @param bool    $full   If enabled, the callstack is not compacted
+        * @param integer $depth   How many calls to include in the stacks after filtering
+        * @param int     $offset  How many calls to shave off the top of the stack, for example if
+        *                         this is called from a centralized method that isn't relevant to the callstack
+        * @param bool    $full    If enabled, the callstack is not compacted
+        * @param array   $exclude 
         * @return string
         */
-       public static function callstack(int $depth = 4, int $offset = 0, bool $full = false): string
+       public static function callstack(int $depth = 4, int $offset = 0, bool $full = false, array $exclude = []): string
        {
                $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
 
@@ -247,6 +248,10 @@ class System
 
                while ($func = array_pop($trace)) {
                        if (!empty($func['class'])) {
+                               if (in_array($func['class'], $exclude)) {
+                                       continue;
+                               }
+
                                if (!$full && in_array($previous['function'], ['insert', 'fetch', 'toArray', 'exists', 'count', 'selectFirst', 'selectToArray',
                                        'select', 'update', 'delete', 'selectFirstForUser', 'selectForUser'])
                                        && (substr($previous['class'], 0, 15) === 'Friendica\Model')) {