2023-01-17 20:22:43 +00:00
|
|
|
#pragma once
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2023-03-13 08:08:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
2023-03-13 08:49:28 +00:00
|
|
|
#define LOGGER_VAR_DECL extern "C" { unsigned int logger_verbosity = 0; }
|
|
|
|
#else
|
|
|
|
#define LOGGER_VAR_DECL unsigned int logger_verbosity = 0
|
2023-03-13 08:08:44 +00:00
|
|
|
#endif
|
|
|
|
|
2023-03-13 08:49:28 +00:00
|
|
|
extern unsigned int logger_verbosity;
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
logger_set_verbosity(unsigned int v)
|
|
|
|
{
|
|
|
|
logger_verbosity = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned int
|
|
|
|
logger_get_verbosity(void)
|
|
|
|
{
|
|
|
|
return logger_verbosity;
|
|
|
|
}
|
2023-03-13 08:08:44 +00:00
|
|
|
|
|
|
|
#define DEBUG_VERBOSITY (2)
|
|
|
|
#define INFO_VERBOSITY (1)
|
|
|
|
|
2023-03-13 08:49:28 +00:00
|
|
|
#define W(fmt, ...) \
|
|
|
|
do { \
|
|
|
|
fprintf(stderr, "[WARNING] %s: " fmt, __func__, ##__VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define E(fmt, ...) \
|
|
|
|
do { \
|
|
|
|
fprintf(stderr, "[ERROR] %s: " fmt, __func__, ##__VA_ARGS__); \
|
|
|
|
exit(1); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define V(fmt, ...) \
|
|
|
|
do { \
|
|
|
|
if (logger_get_verbosity() >= INFO_VERBOSITY) { \
|
|
|
|
fprintf(stdout, "[INFO] %s: " fmt, __func__, ##__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define D(fmt, ...) \
|
|
|
|
do { \
|
|
|
|
if (logger_get_verbosity() >= DEBUG_VERBOSITY) { \
|
|
|
|
fprintf(stdout, "[DEBUG] %s: " fmt, __func__, ##__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2023-03-13 08:08:44 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|