Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,19 @@ jobs:
matrix:
php: [ '8.1', '8.2', '8.3', '8.4' ]
monolog: [ '2.*' ]
symfony: [ '6.4.*' ]
symfony: [ false ]
include:
- php: '7.2'
symfony: '5.4.*'
monolog: '1.*'
- php: '7.4'
- php: '8.1'
deps: lowest
symfony: '5.4.*'
symfony: '6.4.*'
monolog: '1.*'
deprecations: max[self]=0
- php: '8.1'
monolog: '3.*'
symfony: '6.4.*'
- php: '8.2'
monolog: '3.*'
symfony: '7.3.*'
- php: '8.3'
monolog: '3.*'
symfony: '7.3.*'
- php: '8.4'
deps: highest
monolog: '3.*'
symfony: '7.4.*'

env:
SYMFONY_REQUIRE: ${{ matrix.symfony }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Add `slack.exclude_fields` and `slackwebhook.exclude_fields` configuration
* Add a processor to all loggers only when tags do not specify a channel or handler
* Deprecate abstract `monolog.activation_strategy.not_found` and `monolog.handler.fingers_crossed.error_level_activation_strategy` service definitions
* Drop support for PHP < 8.1
* Drop support for Symfony < 6.4

## 3.10.0 (2023-11-06)

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
}
],
"require": {
"php": ">=7.2.5",
"php": ">=8.1",
"composer-runtime-api": "^2.0",
"monolog/monolog": "^1.25.1 || ^2.0 || ^3.0",
"symfony/config": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
"symfony/monolog-bridge": "^5.4 || ^6.0 || ^7.0",
"symfony/config": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0",
"symfony/monolog-bridge": "^6.4 || ^7.0",
"symfony/polyfill-php84": "^1.30"
},
"require-dev": {
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/console": "^6.4 || ^7.0",
"symfony/phpunit-bridge": "^7.1",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
"symfony/yaml": "^6.4 || ^7.0"
},
"autoload": {
"psr-4": { "Symfony\\Bundle\\MonologBundle\\": "src" }
Expand Down
38 changes: 17 additions & 21 deletions src/DependencyInjection/MonologExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Monolog\Processor\PsrLogMessageProcessor;
use Monolog\ResettableInterface;
use Symfony\Bridge\Monolog\Handler\FingersCrossed\HttpCodeActivationStrategy;
use Symfony\Bridge\Monolog\Logger as LegacyLogger;
use Symfony\Bridge\Monolog\Processor\SwitchUserTokenProcessor;
use Symfony\Bridge\Monolog\Processor\TokenProcessor;
use Symfony\Bridge\Monolog\Processor\WebProcessor;
Expand All @@ -32,7 +31,6 @@
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\HttpKernel\Log\DebugLoggerConfigurator;
use Symfony\Contracts\HttpClient\HttpClientInterface;

/**
Expand Down Expand Up @@ -64,10 +62,6 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../config'));
$loader->load('monolog.php');

if (!class_exists(DebugLoggerConfigurator::class)) {
$container->getDefinition('monolog.logger_prototype')->setClass(LegacyLogger::class);
}

$container->setParameter('monolog.use_microseconds', $config['use_microseconds']);

$handlers = [];
Expand Down Expand Up @@ -116,30 +110,29 @@ public function load(array $configs, ContainerBuilder $container)
}
$container->registerForAutoconfiguration(TokenProcessor::class)
->addTag('monolog.processor');

if (interface_exists(HttpClientInterface::class)) {
$handlerAutoconfiguration = $container->registerForAutoconfiguration(HandlerInterface::class);
$handlerAutoconfiguration->setBindings($handlerAutoconfiguration->getBindings() + [
HttpClientInterface::class => new BoundArgument(new Reference('monolog.http_client'), false),
]);
}

if (80000 <= \PHP_VERSION_ID) {
$container->registerAttributeForAutoconfiguration(AsMonologProcessor::class, static function (ChildDefinition $definition, AsMonologProcessor $attribute, \Reflector $reflector): void {
$tagAttributes = get_object_vars($attribute);
if ($reflector instanceof \ReflectionMethod) {
if (isset($tagAttributes['method'])) {
throw new \LogicException(\sprintf('AsMonologProcessor attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
}

$tagAttributes['method'] = $reflector->getName();
$container->registerAttributeForAutoconfiguration(AsMonologProcessor::class, static function (ChildDefinition $definition, AsMonologProcessor $attribute, \Reflector $reflector): void {
$tagAttributes = get_object_vars($attribute);
if ($reflector instanceof \ReflectionMethod) {
if (isset($tagAttributes['method'])) {
throw new \LogicException(\sprintf('AsMonologProcessor attribute cannot declare a method on "%s::%s()".', $reflector->class, $reflector->name));
}

$definition->addTag('monolog.processor', $tagAttributes);
});
$container->registerAttributeForAutoconfiguration(WithMonologChannel::class, static function (ChildDefinition $definition, WithMonologChannel $attribute): void {
$definition->addTag('monolog.logger', ['channel' => $attribute->channel]);
});
}
$tagAttributes['method'] = $reflector->getName();
}

$definition->addTag('monolog.processor', $tagAttributes);
});
$container->registerAttributeForAutoconfiguration(WithMonologChannel::class, static function (ChildDefinition $definition, WithMonologChannel $attribute): void {
$definition->addTag('monolog.logger', ['channel' => $attribute->channel]);
});
}

/**
Expand Down Expand Up @@ -877,20 +870,23 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
$handler['bubble'],
]);
break;

case 'newrelic':
$definition->setArguments([
$handler['level'],
$handler['bubble'],
$handler['app_name'],
]);
break;

case 'server_log':
$definition->setArguments([
$handler['host'],
$handler['level'],
$handler['bubble'],
]);
break;

case 'sampling':
$nestedHandlerId = $this->getHandlerId($handler['handler']);
$this->markNestedHandler($nestedHandlerId);
Expand Down
Loading