diff options
Diffstat (limited to 'logging.h')
-rw-r--r-- | logging.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/logging.h b/logging.h new file mode 100644 index 0000000..71e1407 --- /dev/null +++ b/logging.h @@ -0,0 +1,25 @@ +// +// Created by Keuin on 2021/12/28. +// + +#ifndef NETMON_LOGGING_H +#define NETMON_LOGGING_H + +#include <time.h> + +void *log_init(const char *filename); + +void log_free(void *logger); + +void log_print(void *logger, const char *level, time_t ts, const char *filename, int lineno, const char *msg); + +#ifdef DEBUG +#define log_debug(logger, msg) log_print((logger), "DEBUG", time(NULL), __FILE__, __LINE__, (msg)) +#else +#define log_debug(logger, msg) do { (logger); (msg); } while(0) +#endif +#define log_info(logger, msg) log_print((logger), "INFO", time(NULL), __FILE__, __LINE__, (msg)) +#define log_warning(logger, msg) log_print((logger), "WARN", time(NULL), __FILE__, __LINE__, (msg)) +#define log_error(logger, msg) log_print((logger), "ERROR", time(NULL), __FILE__, __LINE__, (msg)) + +#endif //NETMON_LOGGING_H |