1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-28 11:05:05 +01:00

Merge remote-tracking branch 'FGM/master'

This commit is contained in:
Jordi Boggiano
2012-06-19 20:28:04 +02:00
6 changed files with 108 additions and 38 deletions

View File

@@ -32,12 +32,14 @@ class SyslogHandler extends AbstractProcessingHandler
* 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::CRITICAL => LOG_CRIT,
Logger::ALERT => LOG_ALERT,
Logger::DEBUG => LOG_DEBUG,
Logger::INFO => LOG_INFO,
Logger::NOTICE => LOG_NOTICE,
Logger::WARNING => LOG_WARNING,
Logger::ERROR => LOG_ERR,
Logger::CRITICAL => LOG_CRIT,
Logger::ALERT => LOG_ALERT,
Logger::EMERGENCY => LOG_EMERG,
);
/**

View File

@@ -30,6 +30,11 @@ class TestHandler extends AbstractProcessingHandler
return $this->records;
}
public function hasEmergency($record)
{
return $this->hasRecord($record, Logger::EMERGENCY);
}
public function hasAlert($record)
{
return $this->hasRecord($record, Logger::ALERT);
@@ -50,6 +55,11 @@ class TestHandler extends AbstractProcessingHandler
return $this->hasRecord($record, Logger::WARNING);
}
public function hasNotice($record)
{
return $this->hasRecord($record, Logger::NOTICE);
}
public function hasInfo($record)
{
return $this->hasRecord($record, Logger::INFO);
@@ -60,6 +70,11 @@ class TestHandler extends AbstractProcessingHandler
return $this->hasRecord($record, Logger::DEBUG);
}
public function hasEmergencyRecords()
{
return isset($this->recordsByLevel[Logger::EMERGENCY]);
}
public function hasAlertRecords()
{
return isset($this->recordsByLevel[Logger::ALERT]);
@@ -80,6 +95,11 @@ class TestHandler extends AbstractProcessingHandler
return isset($this->recordsByLevel[Logger::WARNING]);
}
public function hasNoticeRecords()
{
return isset($this->recordsByLevel[Logger::NOTICE]);
}
public function hasInfoRecords()
{
return isset($this->recordsByLevel[Logger::INFO]);

View File

@@ -36,6 +36,11 @@ class Logger
*/
const INFO = 200;
/**
* Uncommon events
*/
const NOTICE = 250;
/**
* Exceptional occurrences that are not errors
*
@@ -64,13 +69,20 @@ class Logger
*/
const ALERT = 550;
/**
* Urgent alert.
*/
const EMERGENCY = 600;
protected static $levels = array(
100 => 'DEBUG',
200 => 'INFO',
250 => 'NOTICE',
300 => 'WARNING',
400 => 'ERROR',
500 => 'CRITICAL',
550 => 'ALERT',
600 => 'EMERGENCY',
);
protected $name;
@@ -221,6 +233,18 @@ class Logger
return $this->addRecord(self::INFO, $message, $context);
}
/**
* Adds a log record at the NOTICE level.
*
* @param string $message The log message
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function addNotice($message, array $context = array())
{
return $this->addRecord(self::NOTICE, $message, $context);
}
/**
* Adds a log record at the WARNING level.
*
@@ -269,6 +293,19 @@ class Logger
return $this->addRecord(self::ALERT, $message, $context);
}
/**
* Adds a log record at the EMERGENCY level.
*
* @param string $message The log message
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function addEmergency($message, array $context = array())
{
return $this->addRecord(self::EMERGENCY, $message, $context);
}
/**
* Gets the name of the logging level.
*
@@ -312,7 +349,7 @@ class Logger
/**
* Adds a log record at the DEBUG level.
*
* This method allows to have an easy ZF compatibility.
* This method allows to have an easy ZF/Symfony 2 compatibility.
*
* @param string $message The log message
* @param array $context The log context
@@ -326,7 +363,7 @@ class Logger
/**
* Adds a log record at the INFO level.
*
* This method allows to have an easy ZF compatibility.
* This method allows to have an easy ZF/Symfony 2 compatibility.
*
* @param string $message The log message
* @param array $context The log context
@@ -340,7 +377,7 @@ class Logger
/**
* Adds a log record at the INFO level.
*
* This method allows to have an easy ZF compatibility.
* This method allows to have an easy ZF/Symfony 2 compatibility.
*
* @param string $message The log message
* @param array $context The log context
@@ -348,13 +385,13 @@ class Logger
*/
public function notice($message, array $context = array())
{
return $this->addRecord(self::INFO, $message, $context);
return $this->addRecord(self::NOTICE, $message, $context);
}
/**
* Adds a log record at the WARNING level.
*
* This method allows to have an easy ZF compatibility.
* This method allows to have an easy ZF/Symfony 2 compatibility.
*
* @param string $message The log message
* @param array $context The log context
@@ -368,7 +405,7 @@ class Logger
/**
* Adds a log record at the ERROR level.
*
* This method allows to have an easy ZF compatibility.
* This method allows to have an easy ZF/Symfony 2 compatibility.
*
* @param string $message The log message
* @param array $context The log context
@@ -382,7 +419,7 @@ class Logger
/**
* Adds a log record at the CRITICAL level.
*
* This method allows to have an easy ZF compatibility.
* This method allows to have an easy ZF/Symfony 2 compatibility.
*
* @param string $message The log message
* @param array $context The log context
@@ -396,7 +433,7 @@ class Logger
/**
* Adds a log record at the ALERT level.
*
* This method allows to have an easy ZF compatibility.
* This method allows to have an easy ZF/Symfony 2 compatibility.
*
* @param string $message The log message
* @param array $context The log context
@@ -408,9 +445,9 @@ class Logger
}
/**
* Adds a log record at the ALERT level.
* Adds a log record at the EMERGENCY level.
*
* This method allows to have an easy ZF compatibility.
* This method allows to have an easy ZF/Symfony 2 compatibility.
*
* @param string $message The log message
* @param array $context The log context
@@ -418,6 +455,6 @@ class Logger
*/
public function emerg($message, array $context = array())
{
return $this->addRecord(self::ALERT, $message, $context);
return $this->addRecord(self::EMERGENCY, $message, $context);
}
}