1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 04:37:38 +02:00

Added docblocks

This commit is contained in:
Jordi Boggiano
2011-04-05 22:35:39 +02:00
parent 35bd8f724b
commit 3b0f738b88
3 changed files with 49 additions and 1 deletions

View File

@@ -30,17 +30,38 @@ abstract class AbstractHandler implements HandlerInterface
protected $formatter;
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 = Logger::DEBUG, $bubble = false)
{
$this->level = $level;
$this->bubble = $bubble;
}
/**
* 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.
*/
public function isHandling(array $record)
{
return $record['level'] >= $this->level;
}
/**
* 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.
*/
public function handle(array $record)
{
if ($record['level'] < $this->level) {
@@ -62,6 +83,11 @@ abstract class AbstractHandler implements HandlerInterface
return false === $this->bubble;
}
/**
* Handles a set of records at once
*
* @param array $records array of records
*/
public function handleBatch(array $records)
{
foreach ($records as $record) {
@@ -69,8 +95,19 @@ abstract class AbstractHandler implements HandlerInterface
}
}
/**
* Writes the record down to the log of the implementing handler
*
* @param array $record
* @return void
*/
abstract public function write(array $record);
/**
* Closes the log
*
* This will be called automatically when the object is destroyed
*/
public function close()
{
}

View File

@@ -65,7 +65,7 @@ class RotatingFileHandler extends StreamHandler
}
/**
* Closes the handler.
* {@inheritdoc}
*/
public function close()
{

View File

@@ -26,6 +26,11 @@ class StreamHandler extends AbstractHandler
protected $stream;
protected $url;
/**
* @param string $filename
* @param integer $level
* @param Boolean $bubble
*/
public function __construct($stream, $level = Logger::DEBUG, $bubble = true)
{
parent::__construct($level, $bubble);
@@ -36,6 +41,9 @@ class StreamHandler extends AbstractHandler
}
}
/**
* {@inheritdoc}
*/
public function write(array $record)
{
if (null === $this->stream) {
@@ -51,6 +59,9 @@ class StreamHandler extends AbstractHandler
fwrite($this->stream, (string) $record['message']);
}
/**
* {@inheritdoc}
*/
public function close()
{
if (null !== $this->stream) {