Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 621
Zeile 167... Zeile 167...
167
     * @var int Keeps track of depth to prevent infinite logging loops
167
     * @var int Keeps track of depth to prevent infinite logging loops
168
     */
168
     */
169
    private $logDepth = 0;
169
    private $logDepth = 0;
Zeile 170... Zeile 170...
170
 
170
 
-
 
171
    /**
-
 
172
     * @var \WeakMap<\Fiber, int>|null Keeps track of depth inside fibers to prevent infinite logging loops
-
 
173
     */
-
 
174
    private $fiberLogDepth;
-
 
175
 
171
    /**
176
    /**
172
     * @var bool Whether to detect infinite logging loops
177
     * @var bool Whether to detect infinite logging loops
173
     *
178
     *
174
     * This can be disabled via {@see useLoggingLoopDetection} if you have async handlers that do not play well with this
179
     * This can be disabled via {@see useLoggingLoopDetection} if you have async handlers that do not play well with this
175
     */
180
     */
Zeile 187... Zeile 192...
187
    {
192
    {
188
        $this->name = $name;
193
        $this->name = $name;
189
        $this->setHandlers($handlers);
194
        $this->setHandlers($handlers);
190
        $this->processors = $processors;
195
        $this->processors = $processors;
191
        $this->timezone = $timezone ?: new DateTimeZone(date_default_timezone_get() ?: 'UTC');
196
        $this->timezone = $timezone ?: new DateTimeZone(date_default_timezone_get() ?: 'UTC');
-
 
197
 
-
 
198
        if (\PHP_VERSION_ID >= 80100) {
-
 
199
            // Local variable for phpstan, see https://github.com/phpstan/phpstan/issues/6732#issuecomment-1111118412
-
 
200
            /** @var \WeakMap<\Fiber, int> $fiberLogDepth */
-
 
201
            $fiberLogDepth = new \WeakMap();
-
 
202
            $this->fiberLogDepth = $fiberLogDepth;
-
 
203
        }
192
    }
204
    }
Zeile 193... Zeile 205...
193
 
205
 
194
    public function getName(): string
206
    public function getName(): string
195
    {
207
    {
Zeile 330... Zeile 342...
330
        if (isset(self::RFC_5424_LEVELS[$level])) {
342
        if (isset(self::RFC_5424_LEVELS[$level])) {
331
            $level = self::RFC_5424_LEVELS[$level];
343
            $level = self::RFC_5424_LEVELS[$level];
332
        }
344
        }
Zeile 333... Zeile 345...
333
 
345
 
-
 
346
        if ($this->detectCycles) {
-
 
347
            if (\PHP_VERSION_ID >= 80100 && $fiber = \Fiber::getCurrent()) {
-
 
348
                $this->fiberLogDepth[$fiber] = $this->fiberLogDepth[$fiber] ?? 0;
-
 
349
                $logDepth = ++$this->fiberLogDepth[$fiber];
-
 
350
            } else {
-
 
351
                $logDepth = ++$this->logDepth;
-
 
352
            }
334
        if ($this->detectCycles) {
353
        } else {
335
            $this->logDepth += 1;
354
            $logDepth = 0;
-
 
355
        }
336
        }
356
 
337
        if ($this->logDepth === 3) {
357
        if ($logDepth === 3) {
338
            $this->warning('A possible infinite logging loop was detected and aborted. It appears some of your handler code is triggering logging, see the previous log record for a hint as to what may be the cause.');
358
            $this->warning('A possible infinite logging loop was detected and aborted. It appears some of your handler code is triggering logging, see the previous log record for a hint as to what may be the cause.');
339
            return false;
359
            return false;
340
        } elseif ($this->logDepth >= 5) { // log depth 4 is let through so we can log the warning above
360
        } elseif ($logDepth >= 5) { // log depth 4 is let through, so we can log the warning above
341
            return false;
361
            return false;
Zeile 342... Zeile 362...
342
        }
362
        }
343
 
363
 
Zeile 385... Zeile 405...
385
                    return true;
405
                    return true;
386
                }
406
                }
387
            }
407
            }
388
        } finally {
408
        } finally {
389
            if ($this->detectCycles) {
409
            if ($this->detectCycles) {
-
 
410
                if (isset($fiber)) {
-
 
411
                    $this->fiberLogDepth[$fiber]--;
-
 
412
                } else {
390
                $this->logDepth--;
413
                    $this->logDepth--;
-
 
414
                }
391
            }
415
            }
392
        }
416
        }
Zeile 393... Zeile 417...
393
 
417
 
394
        return null !== $record;
418
        return null !== $record;
Zeile 696... Zeile 720...
696
            throw $e;
720
            throw $e;
697
        }
721
        }
Zeile 698... Zeile 722...
698
 
722
 
699
        ($this->exceptionHandler)($e, $record);
723
        ($this->exceptionHandler)($e, $record);
-
 
724
    }
-
 
725
 
-
 
726
    /**
-
 
727
     * @return array<string, mixed>
-
 
728
     */
-
 
729
    public function __serialize(): array
-
 
730
    {
-
 
731
        return [
-
 
732
            'name' => $this->name,
-
 
733
            'handlers' => $this->handlers,
-
 
734
            'processors' => $this->processors,
-
 
735
            'microsecondTimestamps' => $this->microsecondTimestamps,
-
 
736
            'timezone' => $this->timezone,
-
 
737
            'exceptionHandler' => $this->exceptionHandler,
-
 
738
            'logDepth' => $this->logDepth,
-
 
739
            'detectCycles' => $this->detectCycles,
-
 
740
        ];
-
 
741
    }
-
 
742
 
-
 
743
    /**
-
 
744
     * @param array<string, mixed> $data
-
 
745
     */
-
 
746
    public function __unserialize(array $data): void
-
 
747
    {
-
 
748
        foreach (['name', 'handlers', 'processors', 'microsecondTimestamps', 'timezone', 'exceptionHandler', 'logDepth', 'detectCycles'] as $property) {
-
 
749
            if (isset($data[$property])) {
-
 
750
                $this->$property = $data[$property];
-
 
751
            }
-
 
752
        }
-
 
753
 
-
 
754
        if (\PHP_VERSION_ID >= 80100) {
-
 
755
            // Local variable for phpstan, see https://github.com/phpstan/phpstan/issues/6732#issuecomment-1111118412
-
 
756
            /** @var \WeakMap<\Fiber, int> $fiberLogDepth */
-
 
757
            $fiberLogDepth = new \WeakMap();
-
 
758
            $this->fiberLogDepth = $fiberLogDepth;
-
 
759
        }
700
    }
760
    }