‪TYPO3CMS  10.4
InMemoryLogWriter.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
25 
31 {
35  public static ‪$log = [];
36 
40  private static ‪$memoryLock = false;
41 
49  public function ‪writeLog(‪LogRecord $record): self
50  {
51  // Guard: Locked Writer
52  if (self::$memoryLock === true) {
53  return $this;
54  }
55 
56  // Guard: Memory Usage
58  $this->‪lockWriter();
59  return $this;
60  }
61 
62  self::$log[] = $record;
63 
64  return $this;
65  }
66 
70  protected function ‪lockWriter(): void
71  {
72  self::$memoryLock = true;
74  $record = GeneralUtility::makeInstance(
75  LogRecord::class,
76  'TYPO3.CMS.AdminPanel.Log.InMemoryLogWriter',
77  LogLevel::INFO,
78  '... Further log entries omitted, memory usage too high.'
79  );
80  self::$log[] = $record;
81  }
82 }
‪TYPO3\CMS\Adminpanel\Log
Definition: DoctrineSqlLogger.php:18
‪TYPO3\CMS\Core\Log\LogRecord
Definition: LogRecord.php:22
‪TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter
Definition: InMemoryLogWriter.php:31
‪TYPO3\CMS\Adminpanel\Utility\MemoryUtility\isMemoryConsumptionTooHigh
‪static bool isMemoryConsumptionTooHigh()
Definition: MemoryUtility.php:39
‪TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter\writeLog
‪self writeLog(LogRecord $record)
Definition: InMemoryLogWriter.php:47
‪TYPO3\CMS\Core\Log\Writer\AbstractWriter
Definition: AbstractWriter.php:25
‪TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter\$memoryLock
‪static bool $memoryLock
Definition: InMemoryLogWriter.php:38
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Adminpanel\Utility\MemoryUtility
Definition: MemoryUtility.php:28
‪TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter\lockWriter
‪lockWriter()
Definition: InMemoryLogWriter.php:68
‪TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter\$log
‪static LogRecord[] $log
Definition: InMemoryLogWriter.php:34
‪TYPO3\CMS\Core\Log\LogLevel
Definition: LogLevel.php:24