8000 [3.0][Monolog] Remove deprecated interface and deprecated methods by rosier · Pull Request #13348 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Symfony/Bridge/Monolog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
-----

Expand Down
45 changes: 1 addition & 44 deletions src/Symfony/Bridge/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,60 +12,17 @@
namespace Symfony\Bridge\Monolog;

use Monolog\Logger as BaseLogger;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;

/**
* Logger.
*
* @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()
{
Expand Down
53 changes: 28 additions & 25 deletions src/Symfony/Bridge/Monolog/Tests/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
;

$logger = new Logger('foobar', array($debugHandler));
$this->assertEquals(5, $logger->countErrors());
$handler = new DebugHandler();
$logger = new Logger(__METHOD__, array($handler));

$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());
}
}
0