From: Jesse F. Williamson Date: Wed, 14 Jan 2026 20:35:51 +0000 (-0800) Subject: Add a handy debugging gadget that writes to logs. X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c68402ac92fc3d26ce502ec2b8c0a2a68abd9b2b;p=ceph-ci.git Add a handy debugging gadget that writes to logs. It's surprisingly tricky to set up dout() and get it to work usefully; you actually have to know a lot in order to do it, and even then it can be very finnicky. This is an instrumentation tool intended to make it straight forward to "just log something". Signed-off-by: Jesse F. Williamson --- diff --git a/src/common/dout_fmt.h b/src/common/dout_fmt.h index 036319fc6e3..88d1db2f613 100644 --- a/src/common/dout_fmt.h +++ b/src/common/dout_fmt.h @@ -54,3 +54,25 @@ inline void dout_fmt_use_prefix(std::ostream&) {} fmt::print(*_dout, __VA_ARGS__); \ *_dout << dendl; \ } + +// This is useful for debugging during development, please do NOT leave calls to it lying around in production: +inline void dout_trace(const std::string_view info, const std::string_view msg_tag = "dout-TRACE", const std::source_location sl = std::source_location::current()) +{ + // ...this is an attempt only, as the extension is non-standard-- do NOT count on getting the values back: +#pragma push_macro("dout_subsys") +#pragma push_macro("dout_context") + + #define dout_subsys ceph_subsys_rgw + #define dout_context g_ceph_context + + dout_fmt(0, "{} [{}]: {}", msg_tag, fmt::format("{}#{}", sl.file_name(), sl.function_name()), info); + +#pragma pop_macro("dout_subsys") +#pragma pop_macro("dout_context") +} + +inline void dout_trace(const std::source_location sl = std::source_location::current()) +{ + dout_trace("", "dout-TRACE", sl); +} +