From f53b8e38dc70a2c701171952a89c1db488f813bc Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 29 Jul 2021 22:35:57 -0500 Subject: [PATCH] [ox/std] Make fmt version of logError --- deps/ox/src/ox/std/trace.hpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/deps/ox/src/ox/std/trace.hpp b/deps/ox/src/ox/std/trace.hpp index 5113ad87..89b0ecea 100644 --- a/deps/ox/src/ox/std/trace.hpp +++ b/deps/ox/src/ox/std/trace.hpp @@ -257,6 +257,18 @@ using TraceStream = OutStream; using TraceStream = NullStream; #endif +inline void logError(const char *file, int line, const char *fmt, const Error &err) noexcept { + if (err) { + TraceStream trc(file, line, "ox::error"); + if (err.file != nullptr) { + trc << "Error: (" << err.file << ":" << err.line << "):"; + } else { + trc << "Error:"; + } + trc << sfmt>(fmt, static_cast(err)); + } +} + inline void logError(const char *file, int line, const Error &err) noexcept { if (err) { TraceStream trc(file, line, "ox::error"); @@ -271,7 +283,7 @@ void init(); } -#define oxLogError(err) ox::trace::logError(__FILE__, __LINE__, err) +#define oxLogError(...) ox::trace::logError(__FILE__, __LINE__, __VA_ARGS__) #define oxTrace(...) ox::trace::TraceStream(__FILE__, __LINE__, __VA_ARGS__) #define oxOut(...) ox::trace::OutStream(__FILE__, __LINE__, "stdout", __VA_ARGS__)