[ox/std] Make fmt version of logError

This commit is contained in:
Gary Talent 2021-07-29 22:35:57 -05:00
parent 5d5198bf4c
commit f53b8e38dc

View File

@ -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<BasicString<100>>(fmt, static_cast<uint64_t>(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__)