Ylva And Malin
ym_log.h
Go to the documentation of this file.
1 #pragma once
2 #include <ym_attributes.h>
3 #include <stdarg.h>
4 #include <stdio.h>
5 #include <string.h>
6 
7 #ifdef WIN32
8 #define YM_COLOR_RESET ""
9 #define YM_COLOR_FG_BLACK ""
10 #define YM_COLOR_FG_RED ""
11 #define YM_COLOR_FG_GREEN ""
12 #define YM_COLOR_FG_YELLOW ""
13 #define YM_COLOR_FG_BLUE ""
14 #define YM_COLOR_FG_MAGENTA ""
15 #define YM_COLOR_FG_CYAN ""
16 #define YM_COLOR_FG_GREY ""
17 #define YM_COLOR_FG_WHITE ""
18 
19 #define YM_COLOR_BG_BLACK ""
20 #define YM_COLOR_BG_RED ""
21 #define YM_COLOR_BG_GREEN ""
22 #define YM_COLOR_BG_YELLOW ""
23 #define YM_COLOR_BG_BLUE ""
24 #define YM_COLOR_BG_MAGENTA ""
25 #define YM_COLOR_BG_CYAN ""
26 #define YM_COLOR_BG_GREY ""
27 #define YM_COLOR_BG_WHITE ""
28 
29 #else
30 #define YM_COLOR_RESET "\033[0m"
31 #define YM_COLOR_FG_BLACK "\033[0;30m"
32 #define YM_COLOR_FG_RED "\033[0;31m"
33 #define YM_COLOR_FG_GREEN "\033[0;32m"
34 #define YM_COLOR_FG_YELLOW "\033[0;33m"
35 #define YM_COLOR_FG_BLUE "\033[0;34m"
36 #define YM_COLOR_FG_MAGENTA "\033[0;35m"
37 #define YM_COLOR_FG_CYAN "\033[0;36m"
38 #define YM_COLOR_FG_GREY "\033[0;37m"
39 #define YM_COLOR_FG_WHITE "\033[0m"
40 
41 #define YM_COLOR_BG_BLACK "\033[0;40m"
42 #define YM_COLOR_BG_RED "\033[0;41m"
43 #define YM_COLOR_BG_GREEN "\033[0;42m"
44 #define YM_COLOR_BG_YELLOW "\033[0;43m"
45 #define YM_COLOR_BG_BLUE "\033[0;44m"
46 #define YM_COLOR_BG_MAGENTA "\033[0;45m"
47 #define YM_COLOR_BG_CYAN "\033[0;46m"
48 #define YM_COLOR_BG_GREY "\033[0;47m"
49 #define YM_COLOR_BG_WHITE "\033[0m"
50 #endif
51 
52 
53 
72 void
73 ym_log(FILE* file,
74  const char* type,
75  const char* color,
76  const char* filepath,
77  const char* func,
78  const int line,
79  const char* fmt,
80  ...);
81 
96 #ifdef WIN32
97 #define TERMINAL_PAUSE system("pause");
98 #else
99 #define TERMINAL_PAUSE
100 #endif
101 
102 #define YM_ERROR(fmt, ...) \
103 { \
104  ym_log(stderr, "ERROR", YM_COLOR_FG_RED, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__); \
105  TERMINAL_PAUSE; \
106  exit(EXIT_FAILURE); \
107 }
108 
118 #define YM_WARN(fmt, ...) \
119 ym_log(stderr, "WARN", YM_COLOR_FG_YELLOW, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
120 
130 #define YM_DEBUG(fmt, ...) \
131 ym_log(stdout, "DEBUG", YM_COLOR_FG_CYAN, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
132 
142 #define YM_INFO(fmt, ...) \
143 ym_log(stdout, "INFO", YM_COLOR_FG_WHITE, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
void ym_log(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.
Definition: ym_log.c:7
GLint color
Definition: ym_gfx_sprite.c:19
void GLuint GLenum type
Definition: wglext.h:636