Skip to content

Commit ebffece

Browse files
committed
Monolog 2 compatibility.
1 parent 0105562 commit ebffece

12 files changed

+64
-16
lines changed

UPGRADE-4.3.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,41 @@ Config
55
------
66

77
* Deprecated using environment variables with `cannotBeEmpty()` if the value is validated with `validate()`
8+
9+
MonologBridge
10+
-------------
11+
12+
* Handlers have been made compatible with the interfaces of Monolog 2. If you extend any handlers of MonologBridge,
13+
you need to add return types to certain methods:
14+
15+
Before:
16+
```php
17+
class MyConsoleHandler extends \Symfony\Bridge\Monolog\Handler\ConsoleHandler
18+
{
19+
public function isHandling(array $record)
20+
{
21+
// ...
22+
}
23+
24+
public function handle(array $record)
25+
{
26+
// ..
27+
}
28+
}
29+
```
30+
31+
After:
32+
```php
33+
class MyConsoleHandler extends \Symfony\Bridge\Monolog\Handler\ConsoleHandler
34+
{
35+
public function isHandling(array $record): bool
36+
{
37+
// ...
38+
}
39+
40+
public function handle(array $record): bool
41+
{
42+
// ..
43+
}
44+
}
45+
```

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"doctrine/orm": "~2.4,>=2.4.5",
9898
"doctrine/reflection": "~1.0",
9999
"doctrine/doctrine-bundle": "~1.4",
100-
"monolog/monolog": "~1.11",
100+
"monolog/monolog": "~1.11 || ^2",
101101
"ocramius/proxy-manager": "~0.4|~1.0|~2.0",
102102
"predis/predis": "~1.1",
103103
"egulias/email-validator": "~1.2,>=1.2.8|~2.0",

src/Symfony/Bridge/Monolog/CHANGELOG.md

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

4+
4.3.0
5+
-----
6+
7+
* added experimental support for Monolog 2.
8+
49
4.2.0
510
-----
611

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function onKernelResponse(FilterResponseEvent $event)
5555
/**
5656
* {@inheritdoc}
5757
*/
58-
protected function sendHeader($header, $content)
58+
protected function sendHeader($header, $content): void
5959
{
6060
if (!$this->sendHeaders) {
6161
return;
@@ -71,7 +71,7 @@ protected function sendHeader($header, $content)
7171
/**
7272
* Override default behavior since we check it in onKernelResponse.
7373
*/
74-
protected function headersAccepted()
74+
protected function headersAccepted(): bool
7575
{
7676
return true;
7777
}

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;
@@ -71,15 +72,15 @@ public function __construct(OutputInterface $output = null, bool $bubble = true,
7172
/**
7273
* {@inheritdoc}
7374
*/
74-
public function isHandling(array $record)
75+
public function isHandling(array $record): bool
7576
{
7677
return $this->updateLevel() && parent::isHandling($record);
7778
}
7879

7980
/**
8081
* {@inheritdoc}
8182
*/
82-
public function handle(array $record)
83+
public function handle(array $record): bool
8384
{
8485
// we have to update the logging level each time because the verbosity of the
8586
// console output might have changed in the meantime (it is not immutable)
@@ -97,7 +98,7 @@ public function setOutput(OutputInterface $output)
9798
/**
9899
* Disables the output.
99100
*/
100-
public function close()
101+
public function close(): void
101102
{
102103
$this->output = null;
103104

@@ -140,7 +141,7 @@ public static function getSubscribedEvents()
140141
/**
141142
* {@inheritdoc}
142143
*/
143-
protected function write(array $record)
144+
protected function write(array $record): void
144145
{
145146
// at this point we've determined for sure that we want to output the record, so use the output's own verbosity
146147
$this->output->write((string) $record['formatted'], false, $this->output->getVerbosity());
@@ -149,7 +150,7 @@ protected function write(array $record)
149150
/**
150151
* {@inheritdoc}
151152
*/
152-
protected function getDefaultFormatter()
153+
protected function getDefaultFormatter(): FormatterInterface
153154
{
154155
if (!class_exists(CliDumper::class)) {
155156
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
@@ -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 (!self::$sendHeaders) {
6363
return;
@@ -73,7 +73,7 @@ protected function sendHeader($header, $content)
7373
/**
7474
* Override default behavior since we check the user agent in onKernelResponse.
7575
*/
76-
protected function headersAccepted()
76+
protected function headersAccepted(): bool
7777
{
7878
return true;
7979
}

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
@@ -50,7 +50,7 @@ public function onCliTerminate(ConsoleTerminateEvent $event)
5050
/**
5151
* {@inheritdoc}
5252
*/
53-
protected function send($content, array $records)
53+
protected function send($content, array $records): void
5454
{
5555
parent::send($content, $records);
5656

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