Skip to content

feat(log): Read log level from the env#414

Open
santanusinha wants to merge 2 commits into
DeusData:mainfrom
santanusinha:log-level-from-env
Open

feat(log): Read log level from the env#414
santanusinha wants to merge 2 commits into
DeusData:mainfrom
santanusinha:log-level-from-env

Conversation

@santanusinha
Copy link
Copy Markdown

This PR closes #413.

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

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
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.

Feature: Read log level from the environment

1 participant