mirror of
https://github.com/Seldaek/monolog.git
synced 2025-01-17 04:38:19 +01:00
Remove non-PSR-3 methods for adding log records
This commit is contained in:
parent
35ce15e098
commit
39f8a20e6d
@ -3,3 +3,6 @@
|
||||
- The timezone is now set per Logger instance and not statically, either
|
||||
via ->setTimezone or passed in the constructor. Calls to Logger::setTimezone
|
||||
should be converted.
|
||||
|
||||
- Removed non-PSR-3 methods to add records, all the `add*` (e.g. `addWarning`)
|
||||
methods as well as `emerg`, `crit`, `err` and `warn`.
|
||||
|
@ -328,102 +328,6 @@ class Logger implements LoggerInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the DEBUG level.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addDebug($message, array $context = array())
|
||||
{
|
||||
return $this->addRecord(static::DEBUG, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the INFO level.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addInfo($message, array $context = array())
|
||||
{
|
||||
return $this->addRecord(static::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(static::NOTICE, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the WARNING level.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addWarning($message, array $context = array())
|
||||
{
|
||||
return $this->addRecord(static::WARNING, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the ERROR level.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addError($message, array $context = array())
|
||||
{
|
||||
return $this->addRecord(static::ERROR, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the CRITICAL level.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addCritical($message, array $context = array())
|
||||
{
|
||||
return $this->addRecord(static::CRITICAL, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the ALERT level.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function addAlert($message, array $context = array())
|
||||
{
|
||||
return $this->addRecord(static::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(static::EMERGENCY, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all supported logging levels.
|
||||
*
|
||||
@ -544,20 +448,6 @@ class Logger implements LoggerInterface
|
||||
return $this->addRecord(static::NOTICE, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the WARNING level.
|
||||
*
|
||||
* This method allows for compatibility with common interfaces.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function warn($message, array $context = array())
|
||||
{
|
||||
return $this->addRecord(static::WARNING, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the WARNING level.
|
||||
*
|
||||
@ -572,20 +462,6 @@ class Logger implements LoggerInterface
|
||||
return $this->addRecord(static::WARNING, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the ERROR level.
|
||||
*
|
||||
* This method allows for compatibility with common interfaces.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function err($message, array $context = array())
|
||||
{
|
||||
return $this->addRecord(static::ERROR, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the ERROR level.
|
||||
*
|
||||
@ -600,20 +476,6 @@ class Logger implements LoggerInterface
|
||||
return $this->addRecord(static::ERROR, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the CRITICAL level.
|
||||
*
|
||||
* This method allows for compatibility with common interfaces.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function crit($message, array $context = array())
|
||||
{
|
||||
return $this->addRecord(static::CRITICAL, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the CRITICAL level.
|
||||
*
|
||||
@ -642,20 +504,6 @@ class Logger implements LoggerInterface
|
||||
return $this->addRecord(static::ALERT, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the EMERGENCY level.
|
||||
*
|
||||
* This method allows for compatibility with common interfaces.
|
||||
*
|
||||
* @param string $message The log message
|
||||
* @param array $context The log context
|
||||
* @return Boolean Whether the record has been processed
|
||||
*/
|
||||
public function emerg($message, array $context = array())
|
||||
{
|
||||
return $this->addRecord(static::EMERGENCY, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a log record at the EMERGENCY level.
|
||||
*
|
||||
|
@ -121,7 +121,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
public function testDebug()
|
||||
{
|
||||
$this->debugDispatcher->expects($this->once())->method('dispatchDebug')->with($this->equalTo('test'));
|
||||
$this->initLogger()->addDebug('test');
|
||||
$this->initLogger()->debug('test');
|
||||
}
|
||||
|
||||
public function testDebugContextInMessage()
|
||||
@ -134,7 +134,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
$this->equalTo($expectedMessage),
|
||||
$this->equalTo($tag)
|
||||
);
|
||||
$this->initLogger()->addDebug($message, $context);
|
||||
$this->initLogger()->debug($message, $context);
|
||||
}
|
||||
|
||||
public function testDebugTags($tagsContextKeys = null)
|
||||
@ -151,7 +151,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
$this->equalTo($expectedTags)
|
||||
);
|
||||
$this->connector->setDebugDispatcher($debugDispatcher);
|
||||
$logger->addDebug('test', array($key => $expectedTags));
|
||||
$logger->debug('test', array($key => $expectedTags));
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
public function testOptionEnabled()
|
||||
{
|
||||
$this->debugDispatcher->expects($this->never())->method('dispatchDebug');
|
||||
$this->initLogger(array('enabled' => false))->addDebug('test');
|
||||
$this->initLogger(array('enabled' => false))->debug('test');
|
||||
}
|
||||
|
||||
public function testOptionClassesPartialsTraceIgnore()
|
||||
|
@ -65,7 +65,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
$logger = new Logger('foo');
|
||||
$handler = new TestHandler;
|
||||
$logger->pushHandler($handler);
|
||||
$logger->addWarning('test');
|
||||
$logger->warning('test');
|
||||
list($record) = $handler->getRecords();
|
||||
$this->assertEquals('foo', $record['channel']);
|
||||
}
|
||||
@ -82,7 +82,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
->method('handle');
|
||||
$logger->pushHandler($handler);
|
||||
|
||||
$this->assertTrue($logger->addWarning('test'));
|
||||
$this->assertTrue($logger->warning('test'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,7 +97,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
->method('handle');
|
||||
$logger->pushHandler($handler);
|
||||
|
||||
$this->assertFalse($logger->addWarning('test'));
|
||||
$this->assertFalse($logger->warning('test'));
|
||||
}
|
||||
|
||||
public function testHandlersInCtor()
|
||||
@ -206,7 +206,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
return $record;
|
||||
});
|
||||
$logger->addError('test');
|
||||
$logger->error('test');
|
||||
list($record) = $handler->getRecords();
|
||||
$this->assertTrue($record['extra']['win']);
|
||||
}
|
||||
@ -239,7 +239,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
;
|
||||
$logger->pushProcessor($processor);
|
||||
|
||||
$logger->addError('test');
|
||||
$logger->error('test');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,7 +258,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
$logger->pushProcessor(function ($record) use ($that) {
|
||||
$that->fail('The processor should not be called');
|
||||
});
|
||||
$logger->addAlert('test');
|
||||
$logger->alert('test');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -433,22 +433,14 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider logMethodProvider
|
||||
* @covers Monolog\Logger::addDebug
|
||||
* @covers Monolog\Logger::addInfo
|
||||
* @covers Monolog\Logger::addNotice
|
||||
* @covers Monolog\Logger::addWarning
|
||||
* @covers Monolog\Logger::addError
|
||||
* @covers Monolog\Logger::addCritical
|
||||
* @covers Monolog\Logger::addAlert
|
||||
* @covers Monolog\Logger::addEmergency
|
||||
* @covers Monolog\Logger::debug
|
||||
* @covers Monolog\Logger::info
|
||||
* @covers Monolog\Logger::notice
|
||||
* @covers Monolog\Logger::warn
|
||||
* @covers Monolog\Logger::err
|
||||
* @covers Monolog\Logger::crit
|
||||
* @covers Monolog\Logger::warning
|
||||
* @covers Monolog\Logger::error
|
||||
* @covers Monolog\Logger::critical
|
||||
* @covers Monolog\Logger::alert
|
||||
* @covers Monolog\Logger::emerg
|
||||
* @covers Monolog\Logger::emergency
|
||||
*/
|
||||
public function testLogMethods($method, $expectedLevel)
|
||||
{
|
||||
@ -463,25 +455,15 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
||||
public function logMethodProvider()
|
||||
{
|
||||
return array(
|
||||
// monolog methods
|
||||
array('addDebug', Logger::DEBUG),
|
||||
array('addInfo', Logger::INFO),
|
||||
array('addNotice', Logger::NOTICE),
|
||||
array('addWarning', Logger::WARNING),
|
||||
array('addError', Logger::ERROR),
|
||||
array('addCritical', Logger::CRITICAL),
|
||||
array('addAlert', Logger::ALERT),
|
||||
array('addEmergency', Logger::EMERGENCY),
|
||||
|
||||
// ZF/Sf2 compat methods
|
||||
// PSR-3 methods
|
||||
array('debug', Logger::DEBUG),
|
||||
array('info', Logger::INFO),
|
||||
array('notice', Logger::NOTICE),
|
||||
array('warn', Logger::WARNING),
|
||||
array('err', Logger::ERROR),
|
||||
array('crit', Logger::CRITICAL),
|
||||
array('warning', Logger::WARNING),
|
||||
array('error', Logger::ERROR),
|
||||
array('critical', Logger::CRITICAL),
|
||||
array('alert', Logger::ALERT),
|
||||
array('emerg', Logger::EMERGENCY),
|
||||
array('emergency', Logger::EMERGENCY),
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user