[3.0][Monolog] Remove deprecated interface and deprecated methods

This commit is contained in:
Jan Rosier 2015-01-09 16:33:32 +01:00 committed by Fabien Potencier
parent e1f30c4164
commit 0fa072c859
3 changed files with 34 additions and 68 deletions

View File

@ -1,6 +1,12 @@
CHANGELOG
=========
3.0.0
-----
* deprecated interface `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed
* deprecated methods `Logger::crit()`, `Logger::emerg()`, `Logger::err()` and `Logger::warn()` have been removed
2.4.0
-----

View File

@ -12,7 +12,6 @@
namespace Symfony\Bridge\Monolog;
use Monolog\Logger as BaseLogger;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
/**
@ -20,52 +19,10 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Logger extends BaseLogger implements LoggerInterface, DebugLoggerInterface
class Logger extends BaseLogger implements DebugLoggerInterface
{
/**
* @see Symfony\Component\HttpKernel\Log\DebugLoggerInterface
* @deprecated since version 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible.
*/
public function emerg($message, array $context = array())
{
trigger_error('The '.__METHOD__.' method inherited from the Symfony\Component\HttpKernel\Log\LoggerInterface interface is deprecated since version 2.2 and will be removed in 3.0. Use the emergency() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
return parent::addRecord(BaseLogger::EMERGENCY, $message, $context);
}
/**
* @deprecated since version 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible.
*/
public function crit($message, array $context = array())
{
trigger_error('The '.__METHOD__.' method inherited from the Symfony\Component\HttpKernel\Log\LoggerInterface interface is deprecated since version 2.2 and will be removed in 3.0. Use the method critical() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
return parent::addRecord(BaseLogger::CRITICAL, $message, $context);
}
/**
* @deprecated since version 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible.
*/
public function err($message, array $context = array())
{
trigger_error('The '.__METHOD__.' method inherited from the Symfony\Component\HttpKernel\Log\LoggerInterface interface is deprecated since version 2.2 and will be removed in 3.0. Use the error() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
return parent::addRecord(BaseLogger::ERROR, $message, $context);
}
/**
* @deprecated since version 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible.
*/
public function warn($message, array $context = array())
{
trigger_error('The '.__METHOD__.' method inherited from the Symfony\Component\HttpKernel\Log\LoggerInterface interface is deprecated since version 2.2 and will be removed in 3.0. Use the warning() method instead, which is PSR-3 compatible.', E_USER_DEPRECATED);
return parent::addRecord(BaseLogger::WARNING, $message, $context);
}
/**
* {@inheritdoc}
>>>>>>> 2.7
*/
public function getLogs()
{

View File

@ -11,51 +11,54 @@
namespace Symfony\Bridge\Monolog\Tests;
use Monolog\Handler\TestHandler;
use Symfony\Bridge\Monolog\Handler\DebugHandler;
use Symfony\Bridge\Monolog\Logger;
class LoggerTest extends \PHPUnit_Framework_TestCase
{
public function testGetLogsWithDebugHandler()
{
$expectedLogs = array('foo', 'bar');
$handler = new DebugHandler();
$logger = new Logger(__METHOD__, array($handler));
$debugHandler = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
$debugHandler
->expects($this->any())
->method('getLogs')
->will($this->returnValue($expectedLogs))
;
$logger = new Logger('foobar', array($debugHandler));
$this->assertEquals($expectedLogs, $logger->getLogs());
$this->assertTrue($logger->error('error message'));
$this->assertSame(1, count($logger->getLogs()));
}
public function testGetLogsWithoutDebugHandler()
{
$handler = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
$handler = new TestHandler();
$logger = new Logger(__METHOD__, array($handler));
$logger = new Logger('foobar', array($handler));
$this->assertEquals(array(), $logger->getLogs());
$this->assertTrue($logger->error('error message'));
$this->assertSame(array(), $logger->getLogs());
}
public function testCountErrorsWithDebugHandler()
{
$debugHandler = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
$debugHandler
->expects($this->any())
->method('countErrors')
->will($this->returnValue(5))
;
$handler = new DebugHandler();
$logger = new Logger(__METHOD__, array($handler));
$logger = new Logger('foobar', array($debugHandler));
$this->assertEquals(5, $logger->countErrors());
$this->assertTrue($logger->debug('test message'));
$this->assertTrue($logger->info('test message'));
$this->assertTrue($logger->notice('test message'));
$this->assertTrue($logger->warning('test message'));
$this->assertTrue($logger->error('test message'));
$this->assertTrue($logger->critical('test message'));
$this->assertTrue($logger->alert('test message'));
$this->assertTrue($logger->emergency('test message'));
$this->assertSame(4, $logger->countErrors());
}
public function testCountErrorsWithoutDebugHandler()
{
$handler = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
$handler = new TestHandler();
$logger = new Logger(__METHOD__, array($handler));
$logger = new Logger('foobar', array($handler));
$this->assertEquals(0, $logger->countErrors());
$this->assertTrue($logger->error('error message'));
$this->assertSame(0, $logger->countErrors());
}
}