log: format LOGF output out of line so small guest fiber stacks do not reserve it

This commit is contained in:
nmzik
2026-10-21 03:49:57 +02:00
parent 68d0ba5a81
commit be9e13915d
+8 -2
View File
@@ -51,20 +51,26 @@ inline constexpr auto BrightWhite = fmt::fg(fmt::terminal_color::bright_white)
} // namespace Color
// Out of line, so callers on small guest stacks (fibers) do not reserve the formatting frame.
template <typename... Args>
[[gnu::noinline]] void Printf(fmt::text_style style, const char* format, const Args&... args) {
Write(style, fmt::sprintf(format, args...));
}
} // namespace Log
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LOGF(...) \
do { \
if (!::Log::IsSilent()) { \
::Log::Write(::fmt::sprintf(__VA_ARGS__)); \
::Log::Printf({}, __VA_ARGS__); \
} \
} while (false)
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LOGF_COLOR(style, ...) \
do { \
if (!::Log::IsSilent()) { \
::Log::Write((style), ::fmt::sprintf(__VA_ARGS__)); \
::Log::Printf((style), __VA_ARGS__); \
} \
} while (false)