1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 20:57:36 +02:00

Added CRITICAL and ALERT levels

This commit is contained in:
Jordi Boggiano
2011-05-02 15:39:46 +02:00
parent 252058251d
commit d3e89dbed1
4 changed files with 58 additions and 18 deletions

View File

@@ -26,7 +26,7 @@ You can create many Loggers, each defining a channel (e.g.: db, request, router,
Each Handler also has a Formatter, a default one with settings that make sense will be created if you don't set one. The formatters normalize and format incoming records so that they can be used by the handlers to output useful information.
Custom severity levels are not available. Only four levels (debug, info, warning, error) are present for basic filtering purposes, but for sorting and other use cases that would require flexibility, you should add Processors to the Logger that can add extra information (tags, user ip, ..) to the records before they are handled.
Custom severity levels are not available. Only six levels (debug, info, warning, error, critical, alert) are present for basic filtering purposes, but for sorting and other use cases that would require flexibility, you should add Processors to the Logger that can add extra information (tags, user ip, ..) to the records before they are handled.
Notable Features (non-exhaustive and incomplete)
------------------------------------------------

View File

@@ -33,6 +33,8 @@ class WildfireFormatter extends LineFormatter implements FormatterInterface
Logger::INFO => 'INFO',
Logger::WARNING => 'WARN',
Logger::ERROR => 'ERROR',
Logger::CRITICAL => 'ERROR',
Logger::ALERT => 'ERROR',
);
/**

View File

@@ -37,6 +37,8 @@ class SyslogHandler extends AbstractHandler
Logger::INFO => LOG_INFO,
Logger::WARNING => LOG_WARNING,
Logger::ERROR => LOG_ERR,
Logger::CRITICAL => LOG_CRIT,
Logger::ALERT => LOG_ALERT,
);
/**

View File

@@ -46,11 +46,25 @@ class Logger
*/
const ERROR = 400;
/**
* Critical conditions (component unavailable, etc.)
*/
const CRITICAL = 500;
/**
* Action must be taken immediately (entire service down)
*
* Should trigger alert by sms, email, etc.
*/
const ALERT = 550;
protected static $levels = array(
100 => 'DEBUG',
200 => 'INFO',
300 => 'WARNING',
400 => 'ERROR',
500 => 'CRITICAL',
550 => 'ALERT',
);
protected $name;
@@ -206,6 +220,28 @@ class Logger
return $this->addRecord(self::ERROR, $message);
}
/**
* Adds a log record at the CRITICAL level.
*
* @param string $message The log message
* @return Boolean Whether the record has been processed
*/
public function addCritical($message)
{
return $this->addRecord(self::CRITICAL, $message);
}
/**
* Adds a log record at the ALERT level.
*
* @param string $message The log message
* @return Boolean Whether the record has been processed
*/
public function addAlert($message)
{
return $this->addRecord(self::ALERT, $message);
}
/**
* Gets the name of the logging level.
*
@@ -285,7 +321,7 @@ class Logger
}
/**
* Adds a log record at the ERROR level.
* Adds a log record at the CRITICAL level.
*
* This method allows to have an easy ZF compatibility.
*
@@ -294,11 +330,11 @@ class Logger
*/
public function crit($message)
{
return $this->addRecord(self::ERROR, $message);
return $this->addRecord(self::CRITICAL, $message);
}
/**
* Adds a log record at the ERROR level.
* Adds a log record at the ALERT level.
*
* This method allows to have an easy ZF compatibility.
*
@@ -307,11 +343,11 @@ class Logger
*/
public function alert($message)
{
return $this->addRecord(self::ERROR, $message);
return $this->addRecord(self::ALERT, $message);
}
/**
* Adds a log record at the ERROR level.
* Adds a log record at the ALERT level.
*
* This method allows to have an easy ZF compatibility.
*
@@ -320,6 +356,6 @@ class Logger
*/
public function emerg($message)
{
return $this->addRecord(self::ERROR, $message);
return $this->addRecord(self::ALERT, $message);
}
}