mirror of
https://github.com/Seldaek/monolog.git
synced 2025-02-22 05:52:31 +01:00
Removed Logger::toMonologLevel() code duplication and added relevant tests
This commit is contained in:
parent
d84ba2cb20
commit
2cb4a57490
@ -438,10 +438,8 @@ class Logger implements LoggerInterface
|
||||
*/
|
||||
public function log($level, $message, array $context = array())
|
||||
{
|
||||
if (is_string($level) && defined(__CLASS__.'::'.strtoupper($level))) {
|
||||
$level = constant(__CLASS__.'::'.strtoupper($level));
|
||||
}
|
||||
|
||||
$level = static::toMonologLevel($level);
|
||||
|
||||
return $this->addRecord($level, $message, $context);
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,21 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('ERROR', Logger::getLevelName(Logger::ERROR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Logger::toMonologLevel
|
||||
*/
|
||||
public function testConvertPSR3ToMonologLevel()
|
||||
{
|
||||
$this->assertEquals(Logger::toMonologLevel('debug'), 100);
|
||||
$this->assertEquals(Logger::toMonologLevel('info'), 200);
|
||||
$this->assertEquals(Logger::toMonologLevel('notice'), 250);
|
||||
$this->assertEquals(Logger::toMonologLevel('warning'), 300);
|
||||
$this->assertEquals(Logger::toMonologLevel('error'), 400);
|
||||
$this->assertEquals(Logger::toMonologLevel('critical'), 500);
|
||||
$this->assertEquals(Logger::toMonologLevel('alert'), 550);
|
||||
$this->assertEquals(Logger::toMonologLevel('emergency'), 600);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Logger::getLevelName
|
||||
* @expectedException InvalidArgumentException
|
||||
|
Loading…
x
Reference in New Issue
Block a user