From 88a3cd56846200c883816a2a394c8ae5e466fe21 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Wed, 9 Sep 2026 11:51:08 +0000 Subject: add logger with std::print/println --- include/util/io.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'include/util') diff --git a/include/util/io.h b/include/util/io.h index 6fb2a29..e995af5 100644 --- a/include/util/io.h +++ b/include/util/io.h @@ -13,6 +13,7 @@ #include #include #include +#include #include "global.h" @@ -101,4 +102,31 @@ void safe_output(T x, T_arg ...arg) void unix_error(const char *msg); void app_error(const char *msg); +template +void logger(std::format_string fmt, Args&&... args) +{ + if constexpr (GLOBAL_DEBUG) + { + if (verbose) + { + print(std::clog, fmt, std::forward(args)...); + std::clog.flush(); + } + } +} + +template +void loggerln(std::format_string fmt, Args&&... args) +{ + if constexpr (GLOBAL_DEBUG) + { + if (verbose) + { + println(std::clog, fmt, std::forward(args)...); + std::clog.flush(); + } + } +} + + } -- cgit v1.3.1-4-g156e