Open
Bug 1934531
Opened 9 months ago
Updated 7 months ago
Refactor BounceTrackingProtection logging to use FMT
Categories
(Core :: Privacy: Anti-Tracking, task, P3)
Core
Privacy: Anti-Tracking
Tracking
()
NEW
People
(Reporter: emz, Unassigned)
References
(Blocks 1 open bug)
Details
(Whiteboard: [lang=C++])
Now that we have MOZ_LOG_FMT
we can make logging much nicer.
https://firefox-source-docs.mozilla.org/xpcom/fmt-in-gecko.html
We should replace our MOZ_LOG
uses in BTP with MOZ_LOG_FMT
and also make use of custom formatters so we'll no longer need Describe
methods like here: https://searchfox.org/mozilla-central/rev/6597dd03bad82c891d084eed25cafd0c85fb333e/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingRecord.cpp#75
Reporter | ||
Comment 1•9 months ago
|
||
For logging the service mode field I tried something like this:
namespace fmt {
template <>
struct formatter<::nsIBounceTrackingProtection::Modes> {
constexpr auto parse(format_parse_context& ctx) {
return ctx.begin();
}
template <typename FormatContext>
auto format(const ::nsIBounceTrackingProtection::Modes& mode, FormatContext& ctx) const {
switch (mode) {
case ::nsIBounceTrackingProtection::MODE_DISABLED:
return format_to(ctx.out(), FMT_STRING("MODE_DISABLED"));
case ::nsIBounceTrackingProtection::MODE_ENABLED:
return format_to(ctx.out(), FMT_STRING("MODE_ENABLED"));
case ::nsIBounceTrackingProtection::MODE_ENABLED_STANDBY:
return format_to(ctx.out(), FMT_STRING("MODE_ENABLED_STANDBY"));
case ::nsIBounceTrackingProtection::MODE_ENABLED_DRY_RUN:
return format_to(ctx.out(), FMT_STRING("MODE_ENABLED_DRY_RUN"));
default:
return format_to(ctx.out(), FMT_STRING("UNKNOWN_MODE"));
}
}
};
} // namespace fmt
though there might be more concise ways to do this. Normally you'd define the formatter as part of the class, but I couldn't get that to work for an xpcom generated type.
Reporter | ||
Updated•7 months ago
|
Whiteboard: [lang=C++]
You need to log in
before you can comment on or make changes to this bug.
Description
•