feat(log): Read log level from the env#414
Closed
santanusinha wants to merge 2 commits into
Closed
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
DeusData
added a commit
that referenced
this pull request
Jun 6, 2026
…M_LOG_LEVEL Two reviewed external-fork contributions, re-implemented as clean maintainer code. #406 / PR #407 (thanks @nvt-pankajsharma): a POSIX parent-death watchdog so the stdio MCP server exits when its launching parent dies instead of lingering on stdin. Refactors signal_handler into an idempotent request_shutdown(); a watchdog thread polls getppid() (500ms) and shuts down + exit(0) once the initial ppid (>1) changes; Windows unaffected (#ifndef _WIN32). The fork's getppid()<=1 startup early-exit was dropped (it could wrongly kill a legitimately-launched server during reparent races / in container launchers; the initial_ppid>1 guard already no-ops safely), and thread-create failure is now non-fatal (matches the watcher/HTTP background-thread policy). Adds tests/test_parent_watchdog.sh + scripts/test.sh wiring. #413 / PR #414 (thanks @santanusinha): runtime log-level control via CBM_LOG_LEVEL (case-insensitive debug|info|warn|error|none, or numeric 0..4; unset/unknown leaves the level unchanged). getenv() before threads start (no race). Adds tests/test_log.c cases + README env-var row.
Owner
|
Thank you, @santanusinha — Closing in favor of the distilled commit. Thanks for the clean PR! 🙏 |
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: