5#include <source_location>
12#define IMR_LOG_LEVEL 0
17 inline constexpr std::string_view
color_warn{
"\033[1;33m"};
18 inline constexpr std::string_view
color_info{
"\033[36m"};
21 template <
typename... Args>
22 void base(std::FILE* stream, std::string_view tag, std::string_view color, std::format_string<Args...> fmt, Args&&... args)
24 if (
static_cast<
bool>(isatty(fileno(stream))))
25 std::print(stream,
"{}[imr:{}]\033[0m ", color, tag);
27 std::print(stream,
"[imr:{}] ", tag);
28 std::println(stream, fmt, std::forward<Args>(args)...);
31 template <
typename... Args>
32 void error(std::format_string<Args...> fmt, Args&&... args)
40 inline void perror(std::source_location loc = std::source_location::current())
44 error("{}: {}", loc.function_name()
, std::strerror(errno)
);
47 template <
typename... Args>
48 void warn(std::format_string<Args...> fmt, Args&&... args)
55 template <
typename... Args>
56 void info(std::format_string<Args...> fmt, Args&&... args)
63 template <
typename... Args>
64 void debug(std::format_string<Args...> fmt, Args&&... args)
71 template <
typename... Args>
72 void debug(std::source_location loc = std::source_location::current())
#define IMR_LOG_LEVEL
Definition log.h:12
constexpr std::string_view color_warn
Definition log.h:17
constexpr std::string_view color_info
Definition log.h:18
void base(std::FILE *stream, std::string_view tag, std::string_view color, std::format_string< Args... > fmt, Args &&... args)
Definition log.h:22
constexpr int level
Definition log.h:14
constexpr std::string_view color_error
Definition log.h:16
constexpr std::string_view color_debug
Definition log.h:19
void debug(std::source_location loc=std::source_location::current())
Definition log.h:72
void perror(std::source_location loc=std::source_location::current())
Definition log.h:40
void info(std::format_string< Args... > fmt, Args &&... args)
Definition log.h:56
void debug(std::format_string< Args... > fmt, Args &&... args)
Definition log.h:64
void error(std::format_string< Args... > fmt, Args &&... args)
Definition log.h:32
void warn(std::format_string< Args... > fmt, Args &&... args)
Definition log.h:48
Definition file_descriptor.h:11