Skip to content

Commit

Permalink
UHF-9986: Moved monolog services to helfi_api_base.services.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
tuutti committed Apr 19, 2024
1 parent 8d623e5 commit efa2f31
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
4 changes: 4 additions & 0 deletions documentation/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Errors caught by Drupal will be logged to `php://stdout` by `drupal/monolog` mod

JSON parsing needs to be enabled manually in order for this to work. See https://helsinkisolutionoffice.atlassian.net/wiki/spaces/HELFI/pages/7854817294/Logging+Structured+logs#Configuration-using-openshift-console.

## Usage

Make sure your `settings.php` includes:

```php
Expand All @@ -14,3 +16,5 @@ if (file_exists('modules/contrib/helfi_api_base/monolog.services.yml')) {
$settings['container_yamls'][] = 'modules/contrib/helfi_api_base/monolog.services.yml';
}
```

then enable `monolog` module: `drush en monolog`.
21 changes: 21 additions & 0 deletions helfi_api_base.services.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
parameters:
monolog.channel_handlers:
default:
handlers:
- name: default_conditional_handler
formatter: drush_or_json
helfi_api_base.environment_file: ''
helfi_api_base.default_composer_lock: '%app.root%/../composer.lock'
helfi_api_base.internal_domains:
Expand All @@ -20,6 +25,22 @@ services:
autowire: true
autoconfigure: true

monolog.formatter.drush_or_json:
class: Drupal\monolog\Logger\Formatter\ConditionalFormatter
arguments: [ '@monolog.formatter.drush', '@monolog.formatter.json', '@monolog.condition_resolver.cli' ]
shared: false

monolog.handler.default_conditional_handler:
class: Drupal\monolog\Logger\Handler\ConditionalHandler
arguments:
- '@monolog.handler.drupal.drupaltodrush'
- '@monolog.handler.website'
- '@monolog.condition_resolver.cli'

monolog.handler.website:
class: Monolog\Handler\StreamHandler
arguments: ['php://stdout']

logger.channel.helfi_api_base:
parent: logger.channel_base
arguments: [ 'helfi_api_base' ]
Expand Down
23 changes: 0 additions & 23 deletions monolog.services.yml

This file was deleted.

0 comments on commit efa2f31

Please sign in to comment.