8000 [3.0][Monolog] Remove deprecated interface and deprecated methods · symfony/symfony@0fa072c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0fa072c

Browse files
rosierfabpot
authored andcommitted
[3.0][Monolog] Remove deprecated interface and deprecated methods
1 parent e1f30c4 commit 0fa072c

File tree

3 files changed

+35
-69
lines changed

3 files changed

+35
-69
lines changed

src/Symfony/Bridge/Monolog/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
3.0.0
5+
-----
6+
7+
* deprecated interface `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed
8+
* deprecated methods `Logger::crit()`, `Logger::emerg()`, `Logger::err()` and `Logger::warn()` have been removed
9+
410
2.4.0
511
-----
612

src/Symfony/Bridge/Monolog/Logger.php

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,60 +12,17 @@
1212
namespace Symfony\Bridge\Monolog;
1313

1414
use Monolog\Logger as BaseLogger;
15-
use Symfony\Component\HttpKernel\Log\LoggerInterface;
1615
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
1716

1817
/**
1918
* Logger.
2019
*
2120
* @author Fabien Potencier <fabien@symfony.com>
2221
*/
23-
class Logger extends BaseLogger implements LoggerInterface, DebugLoggerInterface
22+
class Logger extends BaseLogger implements DebugLoggerInterface
2423
{
25-
/**
26-
* @see Symfony\Component\HttpKernel\Log\DebugLoggerInterface
27-
* @deprecated since version 2.2, to be removed in 3.0. Use emergency() which is PSR-3 compatible.
28-
*/
29-
public function emerg($message, array $context = array())
30-
{
31-
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);
32-
33-
return parent::addRecord(BaseLogger::EMERGENCY, $message, $context);
34-
}
35-
36-
/**
37-
* @deprecated since version 2.2, to be removed in 3.0. Use critical() which is PSR-3 compatible.
38-
*/
39-
public function crit($message, array $context = array())
40-
{
41-
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);
42-
43-
return parent::addRecord(BaseLogger::CRITICAL, $message, $context);
44-
}
45-
46-
/**
47-
* @deprecated since version 2.2, to be removed in 3.0. Use error() which is PSR-3 compatible.
48-
*/
49-
public function err($message, array $context = array())
50-
{
51-
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);
52-
53-
return parent::addRecord(BaseLogger::ERROR, $message, $context);
54-
}
55-
56-
/**
57-
* @deprecated since version 2.2, to be removed in 3.0. Use warning() which is PSR-3 compatible.
58-
*/
59-
public function warn($message, array $context = array())
60-
{
61-
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);
62-
63-
return parent::addRecord(BaseLogger::WARNING, $message, $context);
64-
}
65-
6624
/**
6725
* {@inheritdoc}
68-
>>>>>>> 2.7
6926
*/
7027
public function getLogs()
7128
{

src/Symfony/Bridge/Monolog/Tests/LoggerTest.php

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,51 +11,54 @@
1111

1212
namespace Symfony\Bridge\Monolog\Tests;
1313

14+
use Monolog\Handler\TestHandler;
15+
use Symfony\Bridge\Monolog\Handler\DebugHandler;
1416
use Symfony\Bridge\Monolog\Logger;
1517

1618
class LoggerTest extends \PHPUnit_Framework_TestCase
1719
{
1820
public function testGetLogsWithDebugHandler()
1921
{
20-
$expectedLogs = array('foo', 'bar');
22+
$handler = new DebugHandler();
23+
$logger = new Logger(__METHOD__, array($handler));
2124

22-
$debugHandler = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
23-
$debugHandler
24-
->expects($this->any())
25-
->method('getLogs')
26-
->will($this->returnValue($expectedLogs))
27-
;
28-
29-
$logger = new Logger('foobar', array($debugHandler));
30-
$this->assertEquals($expectedLogs, $logger->getLogs());
25+
$this->assertTrue($logger->error('error message'));
26+
$this->assertSame(1, count($logger->getLogs()));
3127
}
3228

3329
public function testGetLogsWithoutDebugHandler()
3430
{
35-
$handler = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
31+
$handler = new TestHandler();
32+
$logger = new Logger(__METHOD__, array($handler));
3633

37-
$logger = new Logger('foobar', array($handler));
38-
$this->assertEquals(array(), $logger->getLogs());
34+
$this->assertTrue($logger->error('error message'));
35+
$this->assertSame(array(), $logger->getLogs());
3936
}
4037

4138
public function testCountErrorsWithDebugHandler()
4239
{
43-
$debugHandler = $this->getMock('Symfony\Component\HttpKernel\Log\DebugLoggerInterface');
44-
$debugHandler
45-
->expects($this->any())
46-
->method('countErrors')
47-
->will($this->returnValue(5))
48-
;
49-
50-
$logger = new Logger('foobar', array($debugHandler));
51-
$this->assertEquals(5, $logger->countErrors());
40+
$handler = new DebugHandler();
41+
$logger = new Logger(__METHOD__, array($handler));
42+
43+
$this->assertTrue($logger->debug('test message'));
44+
$this->assertTrue($logger->info('test message'));
45+
$this->assertTrue($logger->notice('test message'));
46+
$this->assertTrue($logger->warning('test message'));
47+
48+
$this->assertTrue($logger->error('test message'));
49+
$this->assertTrue($logger->critical('test message'));
50+
$this->assertTrue($logger->alert('test message'));
51+
$this->assertTrue($logger->emergency('test message'));
52+
53+
$this->assertSame(4, $logger->countErrors());
5254
}
5355

5456
public function testCountErrorsWithoutDebugHandler()
5557
{
56-
$handler = $this->getMock('Symfony\Component\HttpKernel\Log\LoggerInterface');
58+
$handler = new TestHandler();
59+
$logger = new Logger(__METHOD__, array($handler));
5760

58-
$logger = new Logger('foobar', array($handler));
59-
$this->assertEquals(0, $logger->countErrors());
61+
$this->assertTrue($logger->error('error message'));
62+
$this->assertSame(0, $logger->countErrors());
6063
}
6164
}

0 commit comments

Comments
 (0)
0