52 #define LOG_COLOR_RESET "\033[0m" 53 #define LOG_COLOR_FG_BLACK "\033[0;30m" 54 #define LOG_COLOR_FG_RED "\033[0;31m" 55 #define LOG_COLOR_FG_GREEN "\033[0;32m" 56 #define LOG_COLOR_FG_YELLOW "\033[0;33m" 57 #define LOG_COLOR_FG_BLUE "\033[0;34m" 58 #define LOG_COLOR_FG_MAGENTA "\033[0;35m" 59 #define LOG_COLOR_FG_CYAN "\033[0;36m" 60 #define LOG_COLOR_FG_GREY "\033[0;37m" 61 #define LOG_COLOR_FG_WHITE "\033[0m" 63 #define LOG_COLOR_BG_BLACK "\033[0;40m" 64 #define LOG_COLOR_BG_RED "\033[0;41m" 65 #define LOG_COLOR_BG_GREEN "\033[0;42m" 66 #define LOG_COLOR_BG_YELLOW "\033[0;43m" 67 #define LOG_COLOR_BG_BLUE "\033[0;44m" 68 #define LOG_COLOR_BG_MAGENTA "\033[0;45m" 69 #define LOG_COLOR_BG_CYAN "\033[0;46m" 70 #define LOG_COLOR_BG_GREY "\033[0;47m" 71 #define LOG_COLOR_BG_WHITE "\033[0m" 99 #define LOG_TERMINAL_PAUSE system("pause"); 101 #define LOG_TERMINAL_PAUSE 113 #define LOG_ERROR(fmt, ...) \ 115 log_internal(stderr, "ERROR", LOG_COLOR_FG_RED, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); \ 116 LOG_TERMINAL_PAUSE; \ 117 std::exit(EXIT_FAILURE); \ 125 #define LOG_WARN(fmt, ...) \ 126 log_internal(stderr, "WARN", LOG_COLOR_FG_YELLOW, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); 138 #define LOG_DEBUG(fmt, ...) \ 139 log_internal(stdout, "DEBUG", LOG_COLOR_FG_CYAN, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); 142 #define LOG_DEBUG(fmt, ...) 149 #define LOG_INFO(fmt, ...) \ 150 log_internal(stdout, "INFO", LOG_COLOR_FG_WHITE, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); 155 log_internal_init_for_windows()
157 const auto outputs = { STD_OUTPUT_HANDLE, STD_ERROR_HANDLE };
158 for (
const auto& item : outputs)
160 HANDLE handle = GetStdHandle(item);
161 if (handle == INVALID_HANDLE_VALUE)
165 if (!GetConsoleMode(handle, &mode))
168 mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
169 if (!SetConsoleMode(handle, mode))
182 const char* filepath,
190 static bool initialized =
false;
193 if (!log_internal_init_for_windows())
195 std::fprintf(stderr,
"Could not enable virtual terminal processing, you will not get any terminal colors\n");
204 va_start(args1, fmt);
208 std::size_t
size = 1 + std::vsnprintf(
nullptr, 0, fmt, args1);
209 std::vector<char> buffer(size);
212 std::vsnprintf(buffer.data(),
size, fmt, args2);
216 const char* filename = std::strrchr(filepath,
'\\');
218 const char* filename = std::strrchr(filepath,
'/');
221 filename = (filename)
225 std::fprintf(file,
"%s[%-5s]%s: %-10s: %-10s:%3d: %s\n",
228 line, buffer.data());
GLint color
Definition: ym_gfx_sprite.c:19
typedef HANDLE(WINAPI *PFNWGLCREATEBUFFERREGIONARBPROC)(HDC hDC
int GLenum UINT size
Definition: wglext.h:321
#define LOG_COLOR_RESET
Logger.h ////////////////////////////////////////////////////////////////////////////////////////////...
Definition: logger.h:52
void log_internal(FILE *file, const char *type, const char *color, const char *filepath, const char *func, const int line, const char *fmt,...)
Actual function which is called by log macros.
#define va_copy(dest, src)
Definition: imgui.cpp:1791
void GLuint GLenum type
Definition: wglext.h:636