* This file is part of the Monolog package.
* (c) Jordi Boggiano <j.boggiano@seld.be>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Base Handler class providing the Handler structure
* @author Jordi Boggiano <j.boggiano@seld.be>
abstract class Monolog_Handler_AbstractHandler implements Monolog_Handler_HandlerInterface
protected $level = Monolog_Logger::DEBUG;
protected $bubble = true;
* @var Monolog_Formatter_FormatterInterface
protected $processors = array();
* @param integer $level The minimum logging level at which this handler will be triggered
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
public function __construct($level = Monolog_Logger::DEBUG, $bubble = true)
public function isHandling(array $record)
return $record['level'] >= $this->level;
public function handleBatch(array $records)
foreach ($records as $record) {
* This will be called automatically when the object is destroyed
public function pushProcessor($callback)
if (!is_callable($callback)) {
throw new InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given');
array_unshift($this->processors, $callback);
public function popProcessor()
if (!$this->processors) {
throw new LogicException('You tried to pop from an empty processor stack.');
return array_shift($this->processors);
public function setFormatter(Monolog_Formatter_FormatterInterface $formatter)
$this->formatter = $formatter;
public function getFormatter()
$this->formatter = $this->getDefaultFormatter();
* Sets minimum logging level at which this handler will be triggered.
public function setLevel($level)
* Gets minimum logging level at which this handler will be triggered.
public function getLevel()
* Sets the bubbling behavior.
* @param Boolean $bubble true means that this handler allows bubbling.
* false means that bubbling is not permitted.
public function setBubble($bubble)
* Gets the bubbling behavior.
* @return Boolean true means that this handler allows bubbling.
* false means that bubbling is not permitted.
public function getBubble()
public function __destruct()
* Gets the default formatter.
* @return Monolog_Formatter_FormatterInterface
protected function getDefaultFormatter()
return new Monolog_Formatter_LineFormatter();