diff options
| author | _ov4 <ov4@ov4.org> | 2026-09-09 11:51:08 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-09-09 11:51:08 +0000 |
| commit | 88a3cd56846200c883816a2a394c8ae5e466fe21 (patch) | |
| tree | 6412b96967b9fd13528f20e842707887e08412b2 /include | |
| parent | 7ec58e8db1096e7916f99b84011ddb13a010da75 (diff) | |
add logger with std::print/println
Diffstat (limited to 'include')
| -rw-r--r-- | include/util/io.h | 28 |
1 files changed, 28 insertions, 0 deletions
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 <vector> #include <string> #include <type_traits> +#include <print> #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<class ...Args> +void logger(std::format_string<Args...> fmt, Args&&... args) +{ + if constexpr (GLOBAL_DEBUG) + { + if (verbose) + { + print(std::clog, fmt, std::forward<Args>(args)...); + std::clog.flush(); + } + } +} + +template<class ...Args> +void loggerln(std::format_string<Args...> fmt, Args&&... args) +{ + if constexpr (GLOBAL_DEBUG) + { + if (verbose) + { + println(std::clog, fmt, std::forward<Args>(args)...); + std::clog.flush(); + } + } +} + + } |
