dasHV: env-gated libhv log routing (stderr / stdout / silent)#2684
Merged
Conversation
libhv defaults to its `file_logger` which writes to `bin/libhv.YYYYMMDD.log`.
That file is invisible under `popen`/CI runners — when something inside the
HTTP server hangs or fails to bind, there's no way to see what libhv is
trying to do.
This commit reads `DASLIVE_HV_LOG` at `Module_HV` construction and routes
libhv accordingly:
DASLIVE_HV_LOG=stderr (or =1) -> hlog_set_handler(stderr_logger)
DASLIVE_HV_LOG=stdout -> hlog_set_handler(stdout_logger)
DASLIVE_HV_LOG=silent -> hlog_disable()
`DASLIVE_HV_LOG_LEVEL=DEBUG/INFO/WARN/ERROR` separately overrides the level
(default INFO).
Default unset preserves the existing file-logger behavior — no change for
non-CI users.
Smoke (Windows, `--headless`):
set DASLIVE_HV_LOG=stderr
set DASLIVE_HV_LOG_LEVEL=DEBUG
daslang-live foo.das -- --headless
-> stderr: "INFO http server listening on 0.0.0.0:9090 [HttpServer.cpp:184:http_server_run]"
"DEBUG hloop_new tid=4572 [hloop.c:431:hloop_new]"
"INFO EventLoop started, pid=99632 tid=4572 [HttpServer.cpp:151:loop_thread]"
"DEBUG hloop_run tid=4572 [hloop.c:454:hloop_run]"
Motivation: dasImgui CI hangs on both Linux and macOS in dasHV's HTTP
serving (script's update loop iterates, but /status never responds). Need
visibility into libhv's event loop state to diagnose — file_logger is
unreachable from the popen'd subprocess on the runner.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds environment-variable switches to control how libhv (hlog) emits logs from the dasHV module, primarily to make CI diagnostics visible (stderr/stdout) or disable logging entirely.
Changes:
- Route libhv logging to
stderr,stdout, or disable it viaDASLIVE_HV_LOG. - Allow overriding libhv log level via
DASLIVE_HV_LOG_LEVEL. - Add required includes for env access and libhv logging.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public: | ||
| Module_HV() : Module("dashv") { | ||
| // libhv defaults to file_logger (bin/libhv.YYYYMMDD.log). Invisible | ||
| // under popen + CI runners. Two env-gated opt-outs: |
Comment on lines
+1185
to
+1189
| } else if (!strcmp(route, "silent")) { | ||
| hlog_disable(); | ||
| } | ||
| } | ||
| if (const char * lvl = std::getenv("DASLIVE_HV_LOG_LEVEL")) { |
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.
Summary
Adds an env-gated knob to redirect libhv's logger (
hlog) from its defaultfile_logger(writing tobin/libhv.YYYYMMDD.log) to stderr/stdout, or to silence it entirely.DASLIVE_HV_LOG=stderr(or=1) —hlog_set_handler(stderr_logger)DASLIVE_HV_LOG=stdout—hlog_set_handler(stdout_logger)DASLIVE_HV_LOG=silent—hlog_disable()DASLIVE_HV_LOG_LEVEL=DEBUG|INFO|WARN|ERROR— override default level (INFO)Default unset preserves existing file-logger behavior — zero impact for users not setting the env.
Why now
dasImgui's CI integration tests hang on both Linux and macOS in dasHV's HTTP serving path (script update loop iterates fine, but
/statusnever responds). On Windows the same tests pass cleanly. Hypothesis is something in libhv's POSIX event loop, but the diagnostic data is unreachable — libhv writes to a file inside the popen'd subprocess that the CI runner never surfaces.Routing libhv to stderr makes the event-loop state (
http server listening,hloop_run, accept errors, etc.) visible in CI logs so we can either fix it or confidently pivot to a different transport.Test plan
Smoke verified locally on Windows:
stderr contains:
🤖 Generated with Claude Code