mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-24 10:06:08 +02:00
Added phpdoc for all methods and added the typehint for the FormatterInterface
This commit is contained in:
@@ -41,12 +41,7 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given record will be handled by this handler
|
||||
*
|
||||
* This is mostly done for performance reasons, to avoid calling processors for nothing.
|
||||
*
|
||||
* @param array $record
|
||||
* @return Boolean True if the record can be handled.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isHandling(array $record)
|
||||
{
|
||||
@@ -54,13 +49,7 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a record
|
||||
*
|
||||
* The return value of this function controls the bubbling process of the handler stack.
|
||||
*
|
||||
* @param array $record
|
||||
* @return Boolean True means that this handler handled the record, and that bubbling is not permitted.
|
||||
* False means the record was either not processed or that this handler allows bubbling.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(array $record)
|
||||
{
|
||||
@@ -84,9 +73,7 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a set of records at once
|
||||
*
|
||||
* @param array $records array of records
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handleBatch(array $records)
|
||||
{
|
||||
@@ -104,7 +91,7 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
abstract public function write(array $record);
|
||||
|
||||
/**
|
||||
* Closes the log
|
||||
* Closes the handler.
|
||||
*
|
||||
* This will be called automatically when the object is destroyed
|
||||
*/
|
||||
@@ -112,41 +99,75 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pushProcessor($callback)
|
||||
{
|
||||
array_unshift($this->processors, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function popProcessor()
|
||||
{
|
||||
return array_shift($this->processors);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setFormatter(FormatterInterface $formatter)
|
||||
{
|
||||
$this->formatter = $formatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormatter()
|
||||
{
|
||||
return $this->formatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets minimum logging level at which this handler will be triggered.
|
||||
*
|
||||
* @param integer $level
|
||||
*/
|
||||
public function setLevel($level)
|
||||
{
|
||||
$this->level = $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets minimum logging level at which this handler will be triggered.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getLevel()
|
||||
{
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bubbling behavior.
|
||||
*
|
||||
* @param Boolean $bubble True means that bubbling is not permitted.
|
||||
* False means that this handler allows bubbling.
|
||||
*/
|
||||
public function setBubble($bubble)
|
||||
{
|
||||
$this->bubble = $bubble;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bubbling behavior.
|
||||
*
|
||||
* @return Boolean True means that bubbling is not permitted.
|
||||
* False means that this handler allows bubbling.
|
||||
*/
|
||||
public function getBubble()
|
||||
{
|
||||
return $this->bubble;
|
||||
@@ -157,6 +178,11 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
$this->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default formatter.
|
||||
*
|
||||
* @return FormatterInterface
|
||||
*/
|
||||
protected function getDefaultFormatter()
|
||||
{
|
||||
return new LineFormatter();
|
||||
|
||||
@@ -29,8 +29,8 @@ class BufferHandler extends AbstractHandler
|
||||
|
||||
/**
|
||||
* @param HandlerInterface $handler Handler.
|
||||
* @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
|
||||
* @param Boolean $bubble
|
||||
* @param integer $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
|
||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||
*/
|
||||
public function __construct(HandlerInterface $handler, $bufferSize = 0, $bubble = false)
|
||||
{
|
||||
@@ -40,12 +40,7 @@ class BufferHandler extends AbstractHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a record
|
||||
*
|
||||
* Records are buffered until closing the handler.
|
||||
*
|
||||
* @param array $record Records
|
||||
* @return Boolean Whether the record was handled
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(array $record)
|
||||
{
|
||||
@@ -57,6 +52,9 @@ class BufferHandler extends AbstractHandler
|
||||
return false === $this->bubble;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
$this->handler->handleBatch($this->buffer);
|
||||
|
||||
@@ -32,9 +32,9 @@ class FingersCrossedHandler extends AbstractHandler
|
||||
|
||||
/**
|
||||
* @param callback|HandlerInterface $handler Handler or factory callback($record, $fingersCrossedHandler).
|
||||
* @param int $actionLevel The level at which this handler is triggered.
|
||||
* @param int $actionLevel The minimum logging level at which this handler will be triggered
|
||||
* @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
|
||||
* @param Boolean $bubble
|
||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||
*/
|
||||
public function __construct($handler, $actionLevel = Logger::WARNING, $bufferSize = 0, $bubble = false)
|
||||
{
|
||||
@@ -45,13 +45,7 @@ class FingersCrossedHandler extends AbstractHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a record
|
||||
*
|
||||
* Records are buffered until one of them matches the actionLevel. From then
|
||||
* on, unless reset() is called, all records are passed to the wrapped handler.
|
||||
*
|
||||
* @param array $record Records
|
||||
* @return Boolean Whether the record was handled
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(array $record)
|
||||
{
|
||||
@@ -76,6 +70,7 @@ class FingersCrossedHandler extends AbstractHandler
|
||||
} else {
|
||||
$this->handler->handle($record);
|
||||
}
|
||||
|
||||
return false === $this->bubble;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@ use Monolog\Formatter\FormatterInterface;
|
||||
interface HandlerInterface
|
||||
{
|
||||
/**
|
||||
* Checks whether the handler handles the record.
|
||||
* Checks whether the given record will be handled by this handler.
|
||||
*
|
||||
* This is mostly done for performance reasons, to avoid calling processors for nothing.
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
@@ -30,16 +32,18 @@ interface HandlerInterface
|
||||
/**
|
||||
* Handles a record.
|
||||
*
|
||||
* The return value of this function controls the bubbling process of the handler stack.
|
||||
*
|
||||
* @param array $record The record to handle
|
||||
* @return Boolean Whether the handler stops the propagation in the stack or not.
|
||||
* @return Boolean True means that this handler handled the record, and that bubbling is not permitted.
|
||||
* False means the record was either not processed or that this handler allows bubbling.
|
||||
*/
|
||||
function handle(array $record);
|
||||
|
||||
/**
|
||||
* Handles a set of records.
|
||||
* Handles a set of records at once.
|
||||
*
|
||||
* @param array $records The records to handle (an array of record arrays)
|
||||
* @return Boolean Whether the handler stops the propagation in the stack or not.
|
||||
*/
|
||||
function handleBatch(array $records);
|
||||
|
||||
|
||||
@@ -23,14 +23,21 @@ use Monolog\Logger;
|
||||
*/
|
||||
class NullHandler extends AbstractHandler
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(array $record)
|
||||
{
|
||||
if ($record['level'] < $this->level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false === $this->bubble;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write(array $record)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ class RotatingFileHandler extends StreamHandler
|
||||
/**
|
||||
* @param string $filename
|
||||
* @param integer $maxFiles The maximal amount of files to keep (0 means unlimited)
|
||||
* @param integer $level
|
||||
* @param Boolean $bubble
|
||||
* @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($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true)
|
||||
{
|
||||
@@ -61,7 +61,8 @@ class RotatingFileHandler extends StreamHandler
|
||||
if (null === $this->mustRotate) {
|
||||
$this->mustRotate = !file_exists($this->url);
|
||||
}
|
||||
return parent::write($record);
|
||||
|
||||
parent::write($record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,8 +28,8 @@ class StreamHandler extends AbstractHandler
|
||||
|
||||
/**
|
||||
* @param string $stream
|
||||
* @param integer $level
|
||||
* @param Boolean $bubble
|
||||
* @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($stream, $level = Logger::DEBUG, $bubble = true)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ use Monolog\Logger;
|
||||
class SyslogHandler extends AbstractHandler
|
||||
{
|
||||
/**
|
||||
* Translate Monolog log levels to syslog log priorities.
|
||||
* Translates Monolog log levels to syslog log priorities.
|
||||
*/
|
||||
private $logLevels = array(
|
||||
Logger::DEBUG => LOG_DEBUG,
|
||||
@@ -56,6 +56,13 @@ class SyslogHandler extends AbstractHandler
|
||||
'uucp' => LOG_UUCP,
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $ident
|
||||
* @param mixed $facility
|
||||
* @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($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
|
||||
{
|
||||
parent::__construct($level, $bubble);
|
||||
@@ -83,11 +90,17 @@ class SyslogHandler extends AbstractHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write(array $record)
|
||||
{
|
||||
syslog($this->logLevels[$record['level']], (string) $record['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
closelog();
|
||||
|
||||
@@ -82,9 +82,13 @@ class TestHandler extends AbstractHandler
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write(array $record)
|
||||
{
|
||||
$this->recordsByLevel[$record['level']][] = $record;
|
||||
|
||||
Reference in New Issue
Block a user