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 } // 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 } // namespace Log
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LOGF(...) \ #define LOGF(...) \
do { \ do { \
if (!::Log::IsSilent()) { \ if (!::Log::IsSilent()) { \
::Log::Write(::fmt::sprintf(__VA_ARGS__)); \ ::Log::Printf({}, __VA_ARGS__); \
} \ } \
} while (false) } while (false)
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LOGF_COLOR(style, ...) \ #define LOGF_COLOR(style, ...) \
do { \ do { \
if (!::Log::IsSilent()) { \ if (!::Log::IsSilent()) { \
::Log::Write((style), ::fmt::sprintf(__VA_ARGS__)); \ ::Log::Printf((style), __VA_ARGS__); \
} \ } \
} while (false) } while (false)