Skip to content
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.2.1 - 2024-07-12
### Added
- Added config option `paysera_logging_extra.sentry.minimum_log_level` to set from which level logs will be sent to Sentry
- Added config option `paysera_logging_extra.monolog.minimum_introspection_level` to set from which level logs will be introspected

## 2.2.0
### Added
- Added Symfony ^6 support.
Expand Down
33 changes: 31 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Paysera\LoggingExtraBundle\DependencyInjection;

use Monolog\Logger;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

Expand All @@ -20,8 +21,36 @@ public function getConfigTreeBuilder()
}

$children = $rootNode->children();
$children->scalarNode('application_name')->isRequired();
$children->arrayNode('grouped_exceptions')->prototype('scalar');
$children
->scalarNode('application_name')
->isRequired()
;
$children
->arrayNode('grouped_exceptions')
->prototype('scalar')
;
$children
->arrayNode('monolog')
->addDefaultsIfNotSet()
->children()
->scalarNode('minimum_introspection_level')
->isRequired()
->defaultValue(Logger::ERROR)
->end()
->end()
->end()
;
$children
->arrayNode('sentry')
->addDefaultsIfNotSet()
->children()
->scalarNode('minimum_log_level')
->isRequired()
->defaultValue(Logger::ERROR)
->end()
->end()
->end()
;

return $treeBuilder;
}
Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/PayseraLoggingExtraExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ public function load(array $configs, ContainerBuilder $container)

$container->setParameter('paysera_logging_extra.application_name', $config['application_name']);
$container->setParameter('paysera_logging_extra.grouped_exceptions', $config['grouped_exceptions']);
$container->setParameter('paysera_logging_extra.monolog.minimum_introspection_level', $config['monolog']['minimum_introspection_level']);
$container->setParameter('paysera_logging_extra.sentry.minimum_log_level', $config['sentry']['minimum_log_level']);
}
}
2 changes: 1 addition & 1 deletion src/Resources/config/services/handlers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<argument type="service">
<service class="Sentry\Monolog\Handler">
<argument type="service" id="Sentry\State\HubInterface"/>
<argument type="constant">Monolog\Logger::ERROR</argument>
<argument type="string">%paysera_logging_extra.sentry.minimum_log_level%</argument>
</service>
</argument>
</service>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services/processors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class="Monolog\Processor\IntrospectionProcessor">
<tag name="monolog.processor"/>

<argument>ERROR</argument>
<argument type="string">%paysera_logging_extra.monolog.minimum_introspection_level%</argument>
</service>

<service id="paysera_logging_extra.processor.remove_root_prefix"
Expand Down
2 changes: 2 additions & 0 deletions tests/Functional/Fixtures/config/cases/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ paysera_logging_extra:
application_name: test-application-name
grouped_exceptions:
- Doctrine\DBAL\ConnectionException
sentry:
minimum_log_level: !php/const Monolog\Logger::WARNING
18 changes: 14 additions & 4 deletions tests/Functional/FunctionalMonologConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,20 @@ public function testSentry()
$this->assertEmpty($this->sentryTransport->getEvents());
$this->sentryClient->flush();
$this->assertSameSentryEvents([
['message' => 'Hello world', 'additionals' => [
'monolog.channel' => 'app',
'monolog.level' => 'ERROR',
]],
[
'message' => 'Hello world',
'additionals' => [
'monolog.channel' => 'app',
'monolog.level' => 'WARNING',
],
],
[
'message' => 'Hello world',
'additionals' => [
'monolog.channel' => 'app',
'monolog.level' => 'ERROR',
],
],
], $this->sentryTransport->getEvents());
}

Expand Down