- md5
- 107df8bd7617ea203e4c1c7f724c63c0
- sha1
- add00963256917778ce3f4e7eb859f6a59b2ac36
- sha256
- 7b8fa7f2ad79e05a221aa7a17d90c46a07179f137a90ad080d7d03fb90894b18
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Log\Logger;
use Joomla\CMS\Log\LogEntry;
use Joomla\CMS\Log\Logger;
/**
* Logger class that keeps all entries in memory
*
* @since 4.0.0
*/
class InMemoryLogger extends Logger
{
/**
* List of collected log entries, grouped by $group
*
* @var array
* @since 4.0.0
*/
protected static $logEntries = [];
/**
* Group name to store the entries
*
* @var string
* @since 4.0.0
*/
protected $group = 'default';
/**
* Constructor.
*
* @param array &$options Log object options.
*
* @since 4.0.0
*/
public function __construct(array &$options)
{
parent::__construct($options);
if (!empty($this->options['group'])) {
$this->group = $this->options['group'];
}
}
/**
* Method to add an entry to the log.
*
* @param LogEntry $entry The log entry object to add to the log.
*
* @return void
*
* @since 4.0.0
*/
public function addEntry(LogEntry $entry)
{
static::$logEntries[$this->group][] = $entry;
}
/**
* Returns a list of collected entries.
*
* @return array
*
* @since 4.0.0
*/
public function getCollectedEntries()
{
if (empty(static::$logEntries[$this->group])) {
return [];
}
return static::$logEntries[$this->group];
}
}
The same content is in 5 releases, Joomla 4.2.0-beta3 to 4.2.1-rc2. See them all, or every version of this file.