- md5
- 3e953221953af3f8de22674d6e479d65
- sha1
- ad196863164aec994b9e11b91b8ffd3e3bea6205
- sha256
- 371893cbaa96491af4ff1a8dde1db65c241d9b93e6a9d719ef63e291835fcd09
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Log\Logger;
\defined('JPATH_PLATFORM') or die;
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];
}
}
No other release has this exact content. See every version of this file.