Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40d04ec

Browse files
committed
feature #27905 [MonologBridge] Monolog 2 compatibility (derrabus)
This PR was merged into the 5.0-dev branch. Discussion ---------- [MonologBridge] Monolog 2 compatibility | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27857 | License | MIT | Doc PR | N/A See #27857 for the discussion. This PR adds return types to methods that need to have one in Monolog 2. Notes: * The PR will break userland handlers that extend handlers from Monolog Bridge. * I was unable to come up with a php 7.1 compatible version of `SwiftMailerHandler` that works with Monolog 1 and Monolog 2 because a method we're overriding now has a `string` type-hint on a parameter that wasn't there before. I've „solved“ this with a version switch, but I feel dirty doing this. 🙈 If you have a better solution, please enlighten me. Commits ------- ca1cfec Monolog 2 compatibility.
2 parents e9a2e3f + ca1cfec commit 40d04ec

11 files changed

+16
-14
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"doctrine/reflection": "~1.0",
109109
"doctrine/doctrine-bundle": "^1.5|^2.0",
110110
"masterminds/html5": "^2.6",
111-
"monolog/monolog": "~1.11",
111+
"monolog/monolog": "^1.11|^2",
112112
"nyholm/psr7": "^1.0",
113113
"ocramius/proxy-manager": "^2.1",
114114
"php-http/httplug": "^1.0|^2.0",

src/Symfony/Bridge/Monolog/CHANGELOG.md

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

77
* The methods `DebugProcessor::getLogs()`, `DebugProcessor::countErrors()`, `Logger::getLogs()` and `Logger::countErrors()` have a new `$request` argument.
8+
* Added support for Monolog 2.
89

910
4.4.0
1011
-----

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function onKernelResponse(ResponseEvent $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;

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function onKernelResponse(ResponseEvent $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;

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

src/Symfony/Bridge/Monolog/Logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function clear()
5959
/**
6060
* {@inheritdoc}
6161
*/
62-
public function reset()
62+
public function reset(): void
6363
{
6464
$this->clear();
6565

src/Symfony/Bridge/Monolog/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": "^7.2.9",
20-
"monolog/monolog": "~1.19",
20+
"monolog/monolog": "^1.19|^2",
2121
"symfony/service-contracts": "^1.1",
2222
"symfony/http-kernel": "^4.4|^5.0"
2323
},

0 commit comments

Comments
 (0)