Skip to content

mvfst: configurable logging backend (glog / xlog / disabled)#456

Open
afrind wants to merge 1 commit into
facebook:mainfrom
afrind:export-D106885496
Open

mvfst: configurable logging backend (glog / xlog / disabled)#456
afrind wants to merge 1 commit into
facebook:mainfrom
afrind:export-D106885496

Conversation

@afrind
Copy link
Copy Markdown
Contributor

@afrind afrind commented May 30, 2026

Summary:
Adds a compile-time selector for the mvfst logging backend, mirroring the pattern from the wangle (D106528033) and fizz (D106535580) shims. A new <quic/quic-logging-config.h> defines exactly one of MVFST_LOGGING_GLOG, MVFST_LOGGING_XLOG, or MVFST_LOGGING_DISABLED; CMake derives that from -DMVFST_LOGGING_BACKEND={GLOG,XLOG,DISABLED} (default GLOG, preserving today's behavior), and Buck consumers pick a hand-written variant via the new //quic:logging_config target.

MvfstLogging.h and MvfstCheck.h (and their facebook/*-mobile.h counterparts) become 3-branch shims preserving the existing MVLOG_* / MVVLOG / MVVLOG_IF / MVCHECK* / MVDCHECK* macro surface. Per-backend mapping: GLOG passes through to LOG/VLOG/CHECK; XLOG routes to XLOG(level) / XLOG(DBG##n) / XCHECK* with the saturation table MVFST_LOGGING_DBG_10..30 := DBG9 covering the existing MVVLOG(20) sites in QuicCubic.cpp / QuicReadCodec.cpp / QuicServerTransportTestUtil.h; DISABLED drops to a streamable NoopStream for logging and assert()/std::abort()-based check lambdas. MVCHECK_NOTNULL / MVDCHECK_NOTNULL are emulated under XLOG/DISABLED via a generic lambda since folly does not export XCHECK_NOTNULL.

Mobile composition is preserved as an orthogonal axis: under GLOG, mobile keeps today's LogMessageVoidify dead-code-elim pattern to strip log strings from the binary; under XLOG mobile forwards to plain XLOG (folly's category-level build-time stripping covers it); under DISABLED mobile collapses to the same NoopStream branch as desktop.

A latent ODR issue in QuicBatchWriter.h / QuicGsoBatchWriters.h is fixed in passing — static const size_t kMaxIovecs = 64; is changed to static constexpr so streaming it through XCHECK_LT(... << kMaxIovecs) (which captures by reference) does not require an out-of-class definition. glog's CHECK_LT did not ODR-use the symbol, masking the bug; xlog's XCHECK_LT does.

Differential Revision: D106885496

Summary:
Adds a compile-time selector for the mvfst logging backend, mirroring the pattern from the wangle (D106528033) and fizz (D106535580) shims. A new `<quic/quic-logging-config.h>` defines exactly one of `MVFST_LOGGING_GLOG`, `MVFST_LOGGING_XLOG`, or `MVFST_LOGGING_DISABLED`; CMake derives that from `-DMVFST_LOGGING_BACKEND={GLOG,XLOG,DISABLED}` (default GLOG, preserving today's behavior), and Buck consumers pick a hand-written variant via the new `//quic:logging_config` target.

`MvfstLogging.h` and `MvfstCheck.h` (and their `facebook/*-mobile.h` counterparts) become 3-branch shims preserving the existing `MVLOG_*` / `MVVLOG` / `MVVLOG_IF` / `MVCHECK*` / `MVDCHECK*` macro surface. Per-backend mapping: GLOG passes through to `LOG`/`VLOG`/`CHECK`; XLOG routes to `XLOG(level)` / `XLOG(DBG##n)` / `XCHECK*` with the saturation table `MVFST_LOGGING_DBG_10..30 := DBG9` covering the existing `MVVLOG(20)` sites in `QuicCubic.cpp` / `QuicReadCodec.cpp` / `QuicServerTransportTestUtil.h`; DISABLED drops to a streamable `NoopStream` for logging and `assert()`/`std::abort()`-based check lambdas. `MVCHECK_NOTNULL` / `MVDCHECK_NOTNULL` are emulated under XLOG/DISABLED via a generic lambda since folly does not export `XCHECK_NOTNULL`.

Mobile composition is preserved as an orthogonal axis: under GLOG, mobile keeps today's `LogMessageVoidify` dead-code-elim pattern to strip log strings from the binary; under XLOG mobile forwards to plain XLOG (folly's category-level build-time stripping covers it); under DISABLED mobile collapses to the same NoopStream branch as desktop.

A latent ODR issue in `QuicBatchWriter.h` / `QuicGsoBatchWriters.h` is fixed in passing — `static const size_t kMaxIovecs = 64;` is changed to `static constexpr` so streaming it through `XCHECK_LT(... << kMaxIovecs)` (which captures by reference) does not require an out-of-class definition. glog's `CHECK_LT` did not ODR-use the symbol, masking the bug; xlog's `XCHECK_LT` does.

Differential Revision: D106885496
@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label May 30, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 30, 2026

@afrind has exported this pull request. If you are a Meta employee, you can view the originating Diff in D106885496.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant