File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
src/Symfony/Bridge/Monolog Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 12
12
namespace Symfony \Bridge \Monolog ;
13
13
14
14
use Monolog \Logger as BaseLogger ;
15
+ use Monolog \ResettableInterface ;
15
16
use Symfony \Component \HttpFoundation \Request ;
16
17
use Symfony \Component \HttpKernel \Log \DebugLoggerInterface ;
17
18
use Symfony \Contracts \Service \ResetInterface ;
@@ -73,6 +74,10 @@ public function clear()
73
74
public function reset ()
74
75
{
75
76
$ this ->clear ();
77
+
78
+ if ($ this instanceof ResettableInterface) {
79
+ parent ::reset ();
80
+ }
76
81
}
77
82
78
83
/**
Original file line number Diff line number Diff line change 12
12
namespace Symfony \Bridge \Monolog \Tests ;
13
13
14
14
use Monolog \Handler \TestHandler ;
15
+ use Monolog \ResettableInterface ;
15
16
use PHPUnit \Framework \TestCase ;
16
17
use Symfony \Bridge \Monolog \Logger ;
17
18
use Symfony \Bridge \Monolog \Processor \DebugProcessor ;
@@ -108,6 +109,22 @@ public function testClear()
108
109
$ this ->assertSame (0 , $ logger ->countErrors ());
109
110
}
110
111
112
+ public function testReset ()
113
+ {
114
+ $ handler = new TestHandler ();
115
+ $ logger = new Logger ('test ' , [$ handler ]);
116
+ $ logger ->pushProcessor (new DebugProcessor ());
117
+
118
+ $ logger ->info ('test ' );
119
+ $ logger ->reset ();
120
+
121
+ $ this ->assertEmpty ($ logger ->getLogs ());
122
+ $ this ->assertSame (0 , $ logger ->countErrors ());
123
+ if (class_exists (ResettableInterface::class)) {
124
+ $ this ->assertEmpty ($ handler ->getRecords ());
125
+ }
126
+ }
127
+
111
128
/**
112
129
* @group legacy
113
130
* @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.
You can’t perform that action at this time.
0 commit comments