mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-23 17:46:09 +02:00
Added phpdoc for all methods and added the typehint for the FormatterInterface
This commit is contained in:
@@ -64,16 +64,29 @@ class Logger
|
||||
|
||||
protected $processors = array();
|
||||
|
||||
/**
|
||||
* @param string $name The logging channel
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes an handler on the stack.
|
||||
*
|
||||
* @param HandlerInterface $handler
|
||||
*/
|
||||
public function pushHandler(HandlerInterface $handler)
|
||||
{
|
||||
array_unshift($this->handlers, $handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops an handler from the stack
|
||||
*
|
||||
* @return HandlerInterface
|
||||
*/
|
||||
public function popHandler()
|
||||
{
|
||||
if (!$this->handlers) {
|
||||
@@ -82,11 +95,21 @@ class Logger
|
||||
return array_shift($this->handlers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a processor in the stack.
|
||||
*
|
||||
* @param callable $callback
|
||||
*/
|
||||
public function pushProcessor($callback)
|
||||
{
|
||||
array_unshift($this->processors, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the processor on top of the stack and returns it.
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
public function popProcessor()
|
||||
{
|
||||
if (!$this->processors) {
|
||||
@@ -95,6 +118,13 @@ class Logger
|
||||
return array_shift($this->processors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record.
|
||||
*
|
||||
* @param integer $level The logging level
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addRecord($level, $message)
|
||||
{
|
||||
if (!$this->handlers) {
|
||||
@@ -128,29 +158,60 @@ class Logger
|
||||
false === $this->handlers[$handlerKey]->handle($record)) {
|
||||
$handlerKey++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the DEBUG level.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addDebug($message)
|
||||
{
|
||||
return $this->addRecord(self::DEBUG, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the INFO level.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addInfo($message)
|
||||
{
|
||||
return $this->addRecord(self::INFO, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the WARNING level.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addWarning($message)
|
||||
{
|
||||
return $this->addRecord(self::WARNING, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the ERROR level.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addError($message)
|
||||
{
|
||||
return $this->addRecord(self::ERROR, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the logging level.
|
||||
*
|
||||
* @param integer $level
|
||||
* @return string
|
||||
*/
|
||||
public static function getLevelName($level)
|
||||
{
|
||||
return self::$levels[$level];
|
||||
@@ -158,41 +219,105 @@ class Logger
|
||||
|
||||
// ZF Logger Compat
|
||||
|
||||
/**
|
||||
* Adds a log record at the DEBUG level.
|
||||
*
|
||||
* This method allows to have an esay ZF compatibility.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function debug($message)
|
||||
{
|
||||
return $this->addRecord(self::DEBUG, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the INFO level.
|
||||
*
|
||||
* This method allows to have an esay ZF compatibility.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function info($message)
|
||||
{
|
||||
return $this->addRecord(self::INFO, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the INFO level.
|
||||
*
|
||||
* This method allows to have an esay ZF compatibility.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function notice($message)
|
||||
{
|
||||
return $this->addRecord(self::INFO, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the WARNING level.
|
||||
*
|
||||
* This method allows to have an esay ZF compatibility.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function warn($message)
|
||||
{
|
||||
return $this->addRecord(self::WARNING, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the ERROR level.
|
||||
*
|
||||
* This method allows to have an esay ZF compatibility.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function err($message)
|
||||
{
|
||||
return $this->addRecord(self::ERROR, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the ERROR level.
|
||||
*
|
||||
* This method allows to have an esay ZF compatibility.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function crit($message)
|
||||
{
|
||||
return $this->addRecord(self::ERROR, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the ERROR level.
|
||||
*
|
||||
* This method allows to have an esay ZF compatibility.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function alert($message)
|
||||
{
|
||||
return $this->addRecord(self::ERROR, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the ERROR level.
|
||||
*
|
||||
* This method allows to have an esay ZF compatibility.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function emerg($message)
|
||||
{
|
||||
return $this->addRecord(self::ERROR, $message);
|
||||
|
Reference in New Issue
Block a user