2022-10-02 14:09:25 +08:00
|
|
|
#ifndef WOJ_SANDBOX_LOG_H
|
|
|
|
#define WOJ_SANDBOX_LOG_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
// Log
|
|
|
|
#define COLOR_RED "\x1B[1;31m"
|
|
|
|
#define COLOR_YELLOW "\x1B[1;33m"
|
|
|
|
#define COLOR_GREEN "\x1B[1;32m"
|
2024-01-30 12:26:37 +08:00
|
|
|
#define COLOR_GRAY "\x1B[1;37m"
|
2022-10-02 14:09:25 +08:00
|
|
|
#define COLOR_STDOUT_RESET "\x1B[0m"
|
|
|
|
|
2022-10-09 00:06:07 +08:00
|
|
|
#define _LOG(color, level, fmt, ...) \
|
|
|
|
do { \
|
|
|
|
fprintf(stderr, color "[" level "]\t(%s:%d):\t" fmt COLOR_STDOUT_RESET "\n", __FILE__, __LINE__, \
|
|
|
|
##__VA_ARGS__); \
|
2022-10-02 14:09:25 +08:00
|
|
|
} while (0)
|
|
|
|
|
2024-01-30 12:26:37 +08:00
|
|
|
#define LOG_DEBUG(fmt, ...) _LOG(COLOR_GRAY, "D", fmt, ##__VA_ARGS__)
|
|
|
|
#define LOG_INFO(fmt, ...) _LOG(COLOR_GREEN, "I", fmt, ##__VA_ARGS__)
|
|
|
|
#define LOG_WARN(fmt, ...) _LOG(COLOR_YELLOW, "W", fmt, ##__VA_ARGS__)
|
|
|
|
#define LOG_ERR(fmt, ...) _LOG(COLOR_RED, "E", fmt, ##__VA_ARGS__)
|
2022-10-02 14:09:25 +08:00
|
|
|
|
|
|
|
#endif // WOJ_SANDBOX_LOG_H
|