Skip to content

dasHV: env-gated libhv log routing (stderr / stdout / silent)#2684

Merged
borisbat merged 1 commit into
masterfrom
bbatkin/dashv-log-route-env
May 16, 2026
Merged

dasHV: env-gated libhv log routing (stderr / stdout / silent)#2684
borisbat merged 1 commit into
masterfrom
bbatkin/dashv-log-route-env

Conversation

@borisbat
Copy link
Copy Markdown
Collaborator

Summary

Adds an env-gated knob to redirect libhv's logger (hlog) from its default file_logger (writing to bin/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=stdouthlog_set_handler(stdout_logger)
  • DASLIVE_HV_LOG=silenthlog_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 /status never 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:

set DASLIVE_HV_LOG=stderr
set DASLIVE_HV_LOG_LEVEL=DEBUG
bin/Release/daslang-live.exe foo.das -- --headless

stderr contains:

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]
  • CI builds across linux/darwin15/windows
  • No regression on default-unset behavior (still writes to file)

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 16, 2026 09:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 via DASLIVE_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")) {
@borisbat borisbat merged commit 829b8d7 into master May 16, 2026
30 checks passed
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.

2 participants