Skip to content

Commit 7e243b7

Browse files
committed
Monolog 2 compatibility.
1 parent 09dee17 commit 7e243b7

12 files changed

+56
-16
lines changed

UPGRADE-4.3.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,44 @@ HttpKernel
8888
* Renamed `PostResponseEvent` to `TerminateEvent`
8989
* Deprecated `TranslatorListener` in favor of `LocaleAwareListener`
9090

91+
MonologBridge
92+
-------------
93+
94+
* Handlers have been made compatible with the interfaces of Monolog 2. If you extend any handlers of MonologBridge,
95+
you need to add return types to certain methods:
96+
97+
Before:
98+
```php
99+
class MyConsoleHandler extends \Symfony\Bridge\Monolog\Handler\ConsoleHandler
100+
{
101+
public function isHandling(array $record)
102+
{
103+
// ...
104+
}
105+
106+
public function handle(array $record)
107+
{
108+
// ..
109+
}
110+
}
111+
```
112+
113+
After:
114+
```php
115+
class MyConsoleHandler extends \Symfony\Bridge\Monolog\Handler\ConsoleHandler
116+
{
117+
public function isHandling(array $record): bool
118+
{
119+
// ...
120+
}
121+
122+
public function handle(array $record): bool
123+
{
124+
// ..
125+
}
126+
}
127+
```
128+
91129
Messenger
92130
---------
93131

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"doctrine/reflection": "~1.0",
103103
"doctrine/doctrine-bundle": "~1.4",
104104
"masterminds/html5": "^2.6",
105-
"monolog/monolog": "~1.11",
105+
"monolog/monolog": "~1.11 || ^2",
106106
"nyholm/psr7": "^1.0",
107107
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
108108
"predis/predis": "~1.1",

src/Symfony/Bridge/Monolog/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* added `ConsoleCommandProcessor`: monolog processor that adds command name and arguments
88
* added `RouteProcessor`: monolog processor that adds route name, controller::action and route params
9+
* added experimental support for Monolog 2.
910

1011
4.2.0
1112
-----

src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function onKernelResponse(FilterResponseEvent $event)
5757
/**
5858
* {@inheritdoc}
5959
*/
60-
protected function sendHeader($header, $content)
60+
protected function sendHeader($header, $content): void
6161
{
6262
if (!$this->sendHeaders) {
6363
return;
@@ -73,7 +73,7 @@ protected function sendHeader($header, $content)
7373
/**
7474
* Override default behavior since we check it in onKernelResponse.
7575
*/
76-
protected function headersAccepted()
76+
protected function headersAccepted(): bool
7777
{
7878
return true;
7979
}

src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Monolog\Handler;
1313

14+
use Monolog\Formatter\FormatterInterface;
1415
use Monolog\Formatter\LineFormatter;
1516
use Monolog\Handler\AbstractProcessingHandler;
1617
use Monolog\Logger;
@@ -74,15 +75,15 @@ public function __construct(OutputInterface $output = null, bool $bubble = true,
7475
/**
7576
* {@inheritdoc}
7677
*/
77-
public function isHandling(array $record)
78+
public function isHandling(array $record): bool
7879
{
7980
return $this->updateLevel() && parent::isHandling($record);
8081
}
8182

8283
/**
8384
* {@inheritdoc}
8485
*/
85-
public function handle(array $record)
86+
public function handle(array $record): bool
8687
{
8788
// we have to update the logging level each time because the verbosity of the
8889
// console output might have changed in the meantime (it is not immutable)
@@ -100,7 +101,7 @@ public function setOutput(OutputInterface $output)
100101
/**
101102
* Disables the output.
102103
*/
103-
public function close()
104+
public function close(): void
104105
{
105106
$this->output = null;
106107

@@ -143,7 +144,7 @@ public static function getSubscribedEvents()
143144
/**
144145
* {@inheritdoc}
145146
*/
146-
protected function write(array $record)
147+
protected function write(array $record): void
147148
{
148149
// at this point we've determined for sure that we want to output the record, so use the output's own verbosity
149150
$this->output->write((string) $record['formatted'], false, $this->output->getVerbosity());
@@ -152,7 +153,7 @@ protected function write(array $record)
152153
/**
153154
* {@inheritdoc}
154155
*/
155-
protected function getDefaultFormatter()
156+
protected function getDefaultFormatter(): FormatterInterface
156157
{
157158
if (!class_exists(CliDumper::class)) {
158159
return new LineFormatter();

src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(RequestStack $requestStack, array $exclusions, $acti
4545
$this->exclusions = $exclusions;
4646
}
4747

48-
public function isHandlerActivated(array $record)
48+
public function isHandlerActivated(array $record): bool
4949
{
5050
$isActivated = parent::isHandlerActivated($record);
5151

src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(RequestStack $requestStack, array $excludedUrls, $ac
3434
$this->blacklist = '{('.implode('|', $excludedUrls).')}i';
3535
}
3636

37-
public function isHandlerActivated(array $record)
37+
public function isHandlerActivated(array $record): bool
3838
{
3939
$isActivated = parent::isHandlerActivated($record);
4040

src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function onKernelResponse(FilterResponseEvent $event)
5959
/**
6060
* {@inheritdoc}
6161
*/
62-
protected function sendHeader($header, $content)
62+
protected function sendHeader($header, $content): void
6363
{
6464
if (!self::$sendHeaders) {
6565
return;
@@ -75,7 +75,7 @@ protected function sendHeader($header, $content)
7575
/**
7676
* Override default behavior since we check the user agent in onKernelResponse.
7777
*/
78-
protected function headersAccepted()
78+
protected function headersAccepted(): bool
7979
{
8080
return true;
8181
}

src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(string $host, int $level = Logger::DEBUG, bool $bubb
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function handle(array $record)
42+
public function handle(array $record): bool
4343
{
4444
if (!$this->isHandling($record)) {
4545
return false;

src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function onCliTerminate(ConsoleTerminateEvent $event)
5252
/**
5353
* {@inheritdoc}
5454
*/
55-
protected function send($content, array $records)
55+
protected function send($content, array $records): void
5656
{
5757
parent::send($content, $records);
5858

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy