mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-05 12:47:39 +02:00
Added CRITICAL and ALERT levels
This commit is contained in:
@@ -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)
|
||||
------------------------------------------------
|
||||
|
@@ -29,10 +29,12 @@ class WildfireFormatter extends LineFormatter implements FormatterInterface
|
||||
* Translates Monolog log levels to Wildfire levels.
|
||||
*/
|
||||
private $logLevels = array(
|
||||
Logger::DEBUG => 'LOG',
|
||||
Logger::INFO => 'INFO',
|
||||
Logger::WARNING => 'WARN',
|
||||
Logger::ERROR => 'ERROR',
|
||||
Logger::DEBUG => 'LOG',
|
||||
Logger::INFO => 'INFO',
|
||||
Logger::WARNING => 'WARN',
|
||||
Logger::ERROR => 'ERROR',
|
||||
Logger::CRITICAL => 'ERROR',
|
||||
Logger::ALERT => 'ERROR',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -33,10 +33,12 @@ class SyslogHandler extends AbstractHandler
|
||||
* Translates Monolog log levels to syslog log priorities.
|
||||
*/
|
||||
private $logLevels = array(
|
||||
Logger::DEBUG => LOG_DEBUG,
|
||||
Logger::INFO => LOG_INFO,
|
||||
Logger::WARNING => LOG_WARNING,
|
||||
Logger::ERROR => LOG_ERR,
|
||||
Logger::DEBUG => LOG_DEBUG,
|
||||
Logger::INFO => LOG_INFO,
|
||||
Logger::WARNING => LOG_WARNING,
|
||||
Logger::ERROR => LOG_ERR,
|
||||
Logger::CRITICAL => LOG_CRIT,
|
||||
Logger::ALERT => LOG_ALERT,
|
||||
);
|
||||
|
||||
/**
|
||||
|
@@ -27,12 +27,12 @@ class Logger
|
||||
/**
|
||||
* Debug messages
|
||||
*/
|
||||
const DEBUG = 100;
|
||||
const DEBUG = 100;
|
||||
|
||||
/**
|
||||
* Messages you usually don't want to see
|
||||
*/
|
||||
const INFO = 200;
|
||||
const INFO = 200;
|
||||
|
||||
/**
|
||||
* Exceptional occurences that are not errors
|
||||
@@ -44,13 +44,27 @@ class Logger
|
||||
/**
|
||||
* Errors
|
||||
*/
|
||||
const ERROR = 400;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user