mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-07 13:46:38 +02:00
Added some methods in the HandlerInterface and some typehints
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
|
||||
/**
|
||||
@@ -35,12 +36,12 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
$this->bubble = $bubble;
|
||||
}
|
||||
|
||||
public function isHandling($record)
|
||||
public function isHandling(array $record)
|
||||
{
|
||||
return $record['level'] >= $this->level;
|
||||
}
|
||||
|
||||
public function handle($record)
|
||||
public function handle(array $record)
|
||||
{
|
||||
if ($record['level'] < $this->level) {
|
||||
return false;
|
||||
@@ -61,7 +62,7 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
return false === $this->bubble;
|
||||
}
|
||||
|
||||
abstract public function write($record);
|
||||
abstract public function write(array $record);
|
||||
|
||||
public function close()
|
||||
{
|
||||
@@ -77,7 +78,7 @@ abstract class AbstractHandler implements HandlerInterface
|
||||
return array_shift($this->processors);
|
||||
}
|
||||
|
||||
public function setFormatter($formatter)
|
||||
public function setFormatter(FormatterInterface $formatter)
|
||||
{
|
||||
$this->formatter = $formatter;
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ class FingersCrossedHandler extends AbstractHandler
|
||||
* @param array $record Records
|
||||
* @return Boolean Whether the record was handled
|
||||
*/
|
||||
public function handle($record)
|
||||
public function handle(array $record)
|
||||
{
|
||||
if ($this->buffering) {
|
||||
$this->buffer[] = $record;
|
||||
@@ -85,10 +85,10 @@ class FingersCrossedHandler extends AbstractHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented to comply with the AbstractHandler rqeuirements. Can not be called.
|
||||
* Implemented to comply with the AbstractHandler requirements. Can not be called.
|
||||
*/
|
||||
public function write($record)
|
||||
public function write(array $record)
|
||||
{
|
||||
throw new \LogicException('This method should not be called directly on the FingersCrossedHandler.');
|
||||
throw new \BadMethodCallException('This method should not be called directly on the FingersCrossedHandler.');
|
||||
}
|
||||
}
|
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
|
||||
/**
|
||||
* Interface that all Monolog Handlers must implement
|
||||
*
|
||||
@@ -18,7 +20,46 @@ namespace Monolog\Handler;
|
||||
*/
|
||||
interface HandlerInterface
|
||||
{
|
||||
public function isHandling($record);
|
||||
/**
|
||||
* Checks whether the handler handles the record.
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function isHandling(array $record);
|
||||
|
||||
public function handle($record);
|
||||
/**
|
||||
* Handles a record.
|
||||
*
|
||||
* @param array $record The record to handle
|
||||
* @return Boolean Whether the handler stops the propagation in the stack or not.
|
||||
*/
|
||||
public function handle(array $record);
|
||||
|
||||
/**
|
||||
* Adds a processor in the stack.
|
||||
*
|
||||
* @param callable $callback
|
||||
*/
|
||||
function pushProcessor($callback);
|
||||
|
||||
/**
|
||||
* Removes the processor on top of the stack and returns it.
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
function popProcessor();
|
||||
|
||||
/**
|
||||
* Sets the formatter.
|
||||
*
|
||||
* @param FormatterInterface $formatter
|
||||
*/
|
||||
function setFormatter(FormatterInterface $formatter);
|
||||
|
||||
/**
|
||||
* Gets the formatter.
|
||||
*
|
||||
* @return FormatterInterface
|
||||
*/
|
||||
function getFormatter();
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ use Monolog\Logger;
|
||||
*/
|
||||
class NullHandler extends AbstractHandler
|
||||
{
|
||||
public function handle($record)
|
||||
public function handle(array $record)
|
||||
{
|
||||
if ($record['level'] < $this->level) {
|
||||
return false;
|
||||
@@ -31,7 +31,7 @@ class NullHandler extends AbstractHandler
|
||||
return false === $this->bubble;
|
||||
}
|
||||
|
||||
public function write($record)
|
||||
public function write(array $record)
|
||||
{
|
||||
}
|
||||
}
|
@@ -36,7 +36,7 @@ class StreamHandler extends AbstractHandler
|
||||
}
|
||||
}
|
||||
|
||||
public function write($record)
|
||||
public function write(array $record)
|
||||
{
|
||||
if (null === $this->stream) {
|
||||
if (!$this->url) {
|
||||
|
@@ -85,7 +85,7 @@ class TestHandler extends AbstractHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
public function write($record)
|
||||
public function write(array $record)
|
||||
{
|
||||
$this->recordsByLevel[$record['level']][] = $record;
|
||||
$this->records[] = $record;
|
||||
|
Reference in New Issue
Block a user