Skip to content
Permalink
Browse files

bug #30410 [Monolog] Really reset logger when calling logger::reset()…

… (lyrixx)

This PR was merged into the 4.2 branch.

Discussion
----------

[Monolog] Really reset logger when calling logger::reset()

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

08a20ee [Monolog] Really reset logger when calling logger::reset()
  • Loading branch information...
fabpot committed Mar 5, 2019
2 parents ed78e71 + 08a20ee commit 203cfc47b4417384d4d688e4b76f29ad7cb3da4f
Showing with 22 additions and 0 deletions.
  1. +5 −0 src/Symfony/Bridge/Monolog/Logger.php
  2. +17 −0 src/Symfony/Bridge/Monolog/Tests/LoggerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Bridge\Monolog;
use Monolog\Logger as BaseLogger;
use Monolog\ResettableInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Contracts\Service\ResetInterface;
@@ -73,6 +74,10 @@ public function clear()
public function reset()
{
$this->clear();
if ($this instanceof ResettableInterface) {
parent::reset();
}
}
/**
@@ -12,6 +12,7 @@
namespace Symfony\Bridge\Monolog\Tests;
use Monolog\Handler\TestHandler;
use Monolog\ResettableInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Monolog\Logger;
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
@@ -108,6 +109,22 @@ public function testClear()
$this->assertSame(0, $logger->countErrors());
}
public function testReset()
{
$handler = new TestHandler();
$logger = new Logger('test', [$handler]);
$logger->pushProcessor(new DebugProcessor());
$logger->info('test');
$logger->reset();
$this->assertEmpty($logger->getLogs());
$this->assertSame(0, $logger->countErrors());
if (class_exists(ResettableInterface::class)) {
$this->assertEmpty($handler->getRecords());
}
}
/**
* @group legacy
* @expectedDeprecation The "Symfony\Bridge\Monolog\Logger::getLogs()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.

0 comments on commit 203cfc4

Please sign in to comment.
You can’t perform that action at this time.