feat(log): Read log level from the env#414
Open
santanusinha wants to merge 2 commits into
Open
Conversation
Log level can be set at runtime using the CBM_LOG_LEVEL
environment variable.
Allowed values:
- Numeric:
- 0 - DEBUG
- 1 - INFO
- 2 - WARN
- 3 - ERROR
- 4 - NONE
- Textual:
- DEBUG/debug - DEBUG
- INFO/info - INFO
- WARN/warn - WARN
- ERROR/error - ERROR
- NONE/none - NONE
Unknown values will be ignored and the system will stay at
current behaviour.
Tests added and the README has been updated.
Note: cbm_log_init_from_env() is called on startup once
before the first log statement.
Changes:
- src/foundation/log.c: implement cbm_log_init_from_env()
- src/foundation/log.h: declare cbm_log_init_from_env(); update comment
- src/main.c: call cbm_log_init_from_env() early in main()
- tests/test_log.c: add 5 test cases covering valid strings,
case-insensitivity, unknown values, unset var, and numeric values
- README.md: document CBM_LOG_LEVEL in the environment variables table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR closes #413.
Log level can be set at runtime using the CBM_LOG_LEVEL environment variable.
Allowed values:
Unknown values will be ignored and the system will stay at current behaviour.
Tests added and the README has been updated.
Note: cbm_log_init_from_env() is called on startup once before the first log statement.
Changes: