diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-03-14 11:00:38 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-03-20 23:45:00 +0800 |
| commit | c66fb89392f7332e6da7dfab01d8d0acfd7a9eb1 (patch) | |
| tree | e6436272ed473bbb83629748900387605864dd79 /src/log.hpp | |
| parent | aa37277b893d1bfe589618665f355495082e05b6 (diff) | |
refactor(log): removed redundant overloads
Diffstat (limited to 'src/log.hpp')
| -rw-r--r-- | src/log.hpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/log.hpp b/src/log.hpp index 5e5f1d3..8e7f0c1 100644 --- a/src/log.hpp +++ b/src/log.hpp @@ -3,21 +3,22 @@ #include <format> #include <print> #include <string> +#include <unistd.h> inline void log(FILE *_stream, eFormatType type, std::string str) { std::println(_stream, "{}", NFormatter::fmt(type, str)); } -inline void log(eFormatType type, std::string str) { - log(stdout, type, str); -} - template <typename... Args> void log(FILE *_stream, eFormatType type, std::format_string<Args...> fmt, Args &&...args) { - log(_stream, type, std::format(fmt, std::forward<Args>(args)...)); + std::println(_stream, "{}", NFormatter::fmt(type, fmt, std::forward<Args>(args)...)); +} + +inline void log(eFormatType type, std::string str) { + log(type == ERR ? stderr : stdout, type, str); } template <typename... Args> void log(eFormatType type, std::format_string<Args...> fmt, Args &&...args) { - log(stdout, type, std::format(fmt, std::forward<Args>(args)...)); + log(type == ERR ? stderr : stdout, type, fmt, std::forward<Args>(args)...); } |
