minecraft-pi-reborn/libreborn/include/libreborn/log.h

26 lines
864 B
C
Raw Normal View History

2021-06-17 21:32:24 +00:00
#pragma once
#include <stdio.h>
#include <stdlib.h>
2022-05-03 00:43:52 +00:00
#ifdef __cplusplus
extern "C" {
#endif
// Colors
char *color_reset();
char *color_yellow();
char *color_faint();
char *color_red();
2021-06-17 21:32:24 +00:00
// Logging
2022-04-15 01:12:42 +00:00
#define INFO(format, ...) { fprintf(stderr, "[INFO]: " format "\n", ##__VA_ARGS__); }
2022-05-03 00:43:52 +00:00
#define WARN(format, ...) { fprintf(stderr, "%s[WARN]: " format "%s\n", color_yellow(), ##__VA_ARGS__, color_reset()); }
#define DEBUG(format, ...) { const char *debug = getenv("MCPI_DEBUG"); if (debug != NULL && strlen(debug) > 0) { fprintf(stderr, "%s[DEBUG]: " format "%s\n", color_faint(), ##__VA_ARGS__, color_reset()); } }
#define ERR(format, ...) { fprintf(stderr, "%s[ERR]: (%s:%i): " format "%s\n", color_red(), __FILE__, __LINE__, ##__VA_ARGS__, color_reset()); exit(EXIT_FAILURE); }
2022-04-15 01:12:42 +00:00
#define IMPOSSIBLE() ERR("This Should Never Be Called")
2022-05-03 00:43:52 +00:00
#ifdef __cplusplus
}
#endif