Skip to content

Commit 1a66ff0

Browse files
authored
Merge pull request #300 from derrabus/monolog2-compat
Support for Monolog 2
2 parents 635bb23 + bc52eae commit 1a66ff0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

DependencyInjection/MonologExtension.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@
1111

1212
namespace Symfony\Bundle\MonologBundle\DependencyInjection;
1313

14+
use Monolog\Logger;
1415
use Monolog\Processor\ProcessorInterface;
1516
use Monolog\ResettableInterface;
1617
use Symfony\Bridge\Monolog\Handler\FingersCrossed\HttpCodeActivationStrategy;
1718
use Symfony\Bridge\Monolog\Processor\TokenProcessor;
1819
use Symfony\Bridge\Monolog\Processor\WebProcessor;
20+
use Symfony\Bundle\FullStack;
1921
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2022
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2123
use Symfony\Component\DependencyInjection\ContainerBuilder;
2224
use Symfony\Component\Config\FileLocator;
2325
use Symfony\Component\DependencyInjection\Definition;
2426
use Symfony\Component\DependencyInjection\Reference;
27+
use Symfony\Component\HttpKernel\Kernel;
2528

2629
/**
2730
* MonologExtension is an extension for the Monolog library.
@@ -48,6 +51,10 @@ private function levelToMonologConst($level)
4851
*/
4952
public function load(array $configs, ContainerBuilder $container)
5053
{
54+
if (class_exists(FullStack::class) && Kernel::MAJOR_VERSION < 5 && Logger::API >= 2) {
55+
throw new \RuntimeException('Symfony 5 is required for Monolog 2 support. Please downgrade Monolog to version 1.');
56+
}
57+
5158
$configuration = $this->getConfiguration($configs, $container);
5259
$config = $this->processConfiguration($configuration, $configs);
5360

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"symfony/dependency-injection": "~3.4.10 || ^4.0.10 || ^5.0",
2222
"symfony/config": "~3.4 || ~4.0 || ^5.0",
2323
"symfony/http-kernel": "~3.4 || ~4.0 || ^5.0",
24-
"monolog/monolog": "~1.22"
24+
"monolog/monolog": "~1.22 || ~2.0"
2525
},
2626
"require-dev": {
2727
"symfony/yaml": "~3.4 || ~4.0 || ^5.0",

0 commit comments

Comments
 (0)