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

feat: Add named logger configuration #658

Closed
wants to merge 9 commits into from

Conversation

jsimnz
Copy link
Member

@jsimnz jsimnz commented Jul 23, 2022

Relevant issue(s)

Resolves #413

note: This is a duplicate of #656 intentionally as there was some issue with the Github Actions not being triggered correctly

Description

Supports a new format for configuring loggers that targets specific named loggers. It uses a comma-seperated-value (CSV) list of keyvalues.

eg:
--loglevel error,defra.cli=debug
will set the global level for all loggers to error and then the defra.cli level to debug specifically.

It supports an unbounded number of named logger values.

Additionally, introduces a new cli flag --logger which uses the same format, but for all fields of a specific logger, instead of individual fields of many loggers.

eg:
--logger defra.cli,level=debug,output=stdout,format=json
will set the level to debug, output to stdout, and format to json for the logger named defra.cli.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly (REGENERATE CLI DOCS).
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

Some basic integration tests in tests/integration/cli

Specify the platform(s) on which this was tested:

  • Debian Linux WSL2

@jsimnz jsimnz closed this Jul 23, 2022
jsimnz added a commit that referenced this pull request Jul 31, 2022
There was a bug in the #658 that got merged which effectively broke the entire feature. Tests didn't catch it as they were accidentally poorly defined, as they would pass with the default logger settings as well as the custom ones set in the test.

There are two fixes in this PR that resolves the problem. During review, we decided to switch back the Config.Log from Config.Logger, but the viper Bind calls were still using Bind(logger.loglevel) (old name). Additionally, the validate call on the config.Log struct previously always returned nil (no errors), but was changed recently to validate the available options. But, if the --loglevel option is provided it will set the config.Log.Level to error,defra.cli=info,... for example, which would fail validation. I have no moved the validation rules, as it will be validated anyways later in the call stack (in the ToLoggerConfig).

Lastly, it fixes #694, as an accidental oversight, potentially during a rebase/merge-conflict.
@AndrewSisley AndrewSisley deleted the sisley/feat/I413-log-config-overrides branch October 26, 2023 21:47
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
There was a bug in the sourcenetwork#658 that got merged which effectively broke the entire feature. Tests didn't catch it as they were accidentally poorly defined, as they would pass with the default logger settings as well as the custom ones set in the test.

There are two fixes in this PR that resolves the problem. During review, we decided to switch back the Config.Log from Config.Logger, but the viper Bind calls were still using Bind(logger.loglevel) (old name). Additionally, the validate call on the config.Log struct previously always returned nil (no errors), but was changed recently to validate the available options. But, if the --loglevel option is provided it will set the config.Log.Level to error,defra.cli=info,... for example, which would fail validation. I have no moved the validation rules, as it will be validated anyways later in the call stack (in the ToLoggerConfig).

Lastly, it fixes sourcenetwork#694, as an accidental oversight, potentially during a rebase/merge-conflict.
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.

Support named logger config overrides
2 participants