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