Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configuration: add logging section & ad log_level to configuration_opts #50

Merged

Conversation

olaf-mandel
Copy link
Contributor

@olaf-mandel olaf-mandel commented Oct 5, 2024

Allow to configure both the logging-levels and targets of various loggers by adding a new section logging to the configuration file. Each entry in that section configures one logger / channel. An example config is:

logging:
  - name root
    level: INFO
  - name: foomodule.barcollector:
    level: WARNING
    target: /path/to/my/collector/logfile.log

Add CollectorBase.setLoggers(logger_names) as a means for collectors derived from CollectorBase to easily configure logging-levels. The new method uses the collector_opts.logging_level value (if set in the configuration) to set the logging-level of any loggers given to it.

@cmeissner cmeissner self-requested a review October 6, 2024 08:07
@cmeissner
Copy link
Member

As there is new code introduced, please also provide tests to check the funtionallity.

Copy link
Member

@cmeissner cmeissner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please adapt as proposed

README.md Outdated Show resolved Hide resolved
p3exporter/__init__.py Outdated Show resolved Hide resolved
@olaf-mandel olaf-mandel force-pushed the feature/config-logging_levels branch 2 times, most recently from 3b3e866 to d2bf861 Compare October 6, 2024 10:14
@olaf-mandel
Copy link
Contributor Author

Refactored for testability and added test.

@olaf-mandel olaf-mandel changed the title configuration: add logging_levels section configuration: add logging section & ad log_level to configuration_opts Oct 6, 2024
@cmeissner cmeissner self-requested a review October 6, 2024 18:13
Copy link
Member

@cmeissner cmeissner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some flake8 errors and warnings in your PR. It would be great if you can fix this too.

p3exporter/__init__.py Outdated Show resolved Hide resolved
p3exporter/__init__.py Outdated Show resolved Hide resolved
p3exporter/collector/__init__.py Outdated Show resolved Hide resolved
Allow to configure both the logging-levels and targets of various
loggers by adding a new section `logging` to the configuration file.
Each entry in that section configures one logger / channel. An example
config is:

```yaml
logging:
  - name root
    level: INFO
  - name: foomodule.barcollector:
    level: WARNING
    target: /path/to/my/collector/logfile.log
```
Add `CollectorBase.setLoggers(logger_names)` as a means for collectors
derived from `CollectorBase` to easily configure logging-levels. The new
method uses the `collector_opts.logging_level` value (if set in the
configuration) to set the logging-level of any loggers given to it.
@cmeissner cmeissner merged commit aa9483f into codeaffen:develop Oct 6, 2024
4 checks passed
@olaf-mandel olaf-mandel deleted the feature/config-logging_levels branch October 6, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants