Skip to content

Commit

Permalink
Add OTEL logging
Browse files Browse the repository at this point in the history
  • Loading branch information
GDXbsv committed Sep 18, 2024
1 parent 10be21f commit 5155b5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ return static function (MonologConfig $monolog, ContainerConfigurator $container
$monolog->handler('otel')
->type('service')
->id(Handler::class)
->formatter(OtelFormatter::class)
// log start from info messages (debug is lowest level)
->level('info');

Expand All @@ -134,7 +133,6 @@ Otel:
```
->type('service')
->id(Handler::class)
->formatter(OtelFormatter::class)
```

### Exception context
Expand Down
6 changes: 4 additions & 2 deletions src/Symfony/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Psr\Log\LogLevel;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\inline_service;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $containerConfigurator) {
$s = $containerConfigurator->services();
Expand All @@ -35,12 +36,13 @@
$s->set(GuzzleRequestExceptionContext::class)
->tag('gotphoto_logging.exception_context');

$s->set(OtelFormatter::class);
$s->set(Handler::class)
->arg(
'$loggerProvider',
inline_service(LoggerProviderInterface::class)
->factory([Globals::class, 'loggerProvider']),
)
->arg('$level', LogLevel::INFO);
$s->set(OtelFormatter::class);
->arg('$level', LogLevel::INFO)
->call('setFormatter', [service(OtelFormatter::class)]);
};

0 comments on commit 5155b5f

Please sign in to comment.