diff options
Diffstat (limited to 'include/util/io.h')
| -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(); + } + } +} + + } |
