Skip to content

Init folly XLOG (async by default) and root categories at moqx.*#370

Draft
gmarzot wants to merge 2 commits into
mainfrom
feature/xlog-normalization
Draft

Init folly XLOG (async by default) and root categories at moqx.*#370
gmarzot wants to merge 2 commits into
mainfrom
feature/xlog-normalization

Conversation

@gmarzot
Copy link
Copy Markdown
Contributor

@gmarzot gmarzot commented Jun 1, 2026

Summary

Two small consumer-side changes that complete the moqx half of the logging normalization:

  1. src/main.cpp — declare a compile-time baseline logging config so async writes are on by default:

    FOLLY_INIT_LOGGING_CONFIG(".=INFO; default:async=true,sync_level=WARN");

    Keeps the relay off the log-I/O path; `--logging=...` and the `FOLLY_LOGGING` env var still override at startup.

  2. CMakeLists.txt — root XLOG categories at `moqx.` instead of `src.`:

    add_compile_options(-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/src=moqx)
    add_compile_definitions(
      "FOLLY_XLOG_STRIP_PREFIXES=\"${CMAKE_SOURCE_DIR}:${CMAKE_BINARY_DIR}\""
    )

    moqx sources live under `src/`, but the user-facing logging API expects `moqx` as the top-level category. The macro-prefix-map rewrites `FILE` so xlog auto-derives `moqx.MoqxRelay` etc. The strip-prefixes define covers paths the prefix-map doesn't touch (generated headers under the build dir).

Pairs with upstream moxygen-side work landing the same FOLLY_XLOG_STRIP_PREFIXES pattern there and converting moxygen sources to XLOG.

Test plan

  • Build moqx; verify `--logging moqx=DBG4` selects moqx-rooted categories.
  • Verify async writes (`default:async=true,sync_level=WARN`) — INFO/DBG don't block, WARN+ flushed synchronously.
  • `--logging=...` runtime override still works.

This change is Reviewable

gmarzot added 2 commits May 30, 2026 17:39
Default config: root at INFO, AsyncFileWriter sink, sync_level=WARN so
warnings/errors flush before a crash can lose them. Overridable at runtime
via --logging=<config> or the FOLLY_LOGGING env var (folly::Init wires
both into initLoggingOrDie).

Replaces the placeholder TODO that claimed logging was "handled implicitly
by folly::Init" — folly::Init only calls initLoggingOrDie with empty config,
which yields the LoggerDB default (sync, INFO, stderr). Async-on-by-default
is a stated perf goal for the moqx relay.
Rewrite __FILE__ for moqx sources at compile time so folly XLOG categories
render as moqx.* (e.g. moqx.MoqxRelay) instead of src.* — moqx sources live
under src/, but the user-facing logging API expects 'moqx' as the top-level
category. -fmacro-prefix-map rewrites src/... -> moqx/... in __FILE__; xlog
auto-derives the category from there.

FOLLY_XLOG_STRIP_PREFIXES handles paths the prefix-map doesn't touch (notably
generated headers under the build dir).

Combined with the prior FOLLY_INIT_LOGGING_CONFIG commit, --logging moqx=DBG4
selects moqx-rooted categories and async-by-default keeps the relay off the
log-I/O path.
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.

1 participant