mvfst: configurable logging backend (glog / xlog / disabled)#456
Open
afrind wants to merge 1 commit into
Open
Conversation
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
|
@afrind has exported this pull request. If you are a Meta employee, you can view the originating Diff in D106885496. |
3 tasks
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 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 ofMVFST_LOGGING_GLOG,MVFST_LOGGING_XLOG, orMVFST_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_configtarget.MvfstLogging.handMvfstCheck.h(and theirfacebook/*-mobile.hcounterparts) become 3-branch shims preserving the existingMVLOG_*/MVVLOG/MVVLOG_IF/MVCHECK*/MVDCHECK*macro surface. Per-backend mapping: GLOG passes through toLOG/VLOG/CHECK; XLOG routes toXLOG(level)/XLOG(DBG##n)/XCHECK*with the saturation tableMVFST_LOGGING_DBG_10..30 := DBG9covering the existingMVVLOG(20)sites inQuicCubic.cpp/QuicReadCodec.cpp/QuicServerTransportTestUtil.h; DISABLED drops to a streamableNoopStreamfor logging andassert()/std::abort()-based check lambdas.MVCHECK_NOTNULL/MVDCHECK_NOTNULLare emulated under XLOG/DISABLED via a generic lambda since folly does not exportXCHECK_NOTNULL.Mobile composition is preserved as an orthogonal axis: under GLOG, mobile keeps today's
LogMessageVoidifydead-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.his fixed in passing —static const size_t kMaxIovecs = 64;is changed tostatic constexprso streaming it throughXCHECK_LT(... << kMaxIovecs)(which captures by reference) does not require an out-of-class definition. glog'sCHECK_LTdid not ODR-use the symbol, masking the bug; xlog'sXCHECK_LTdoes.Differential Revision: D106885496