From 94d7588c2045cbe76ec0287a5e92f1b4123d996f Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 28 Dec 2021 05:37:54 +0800 Subject: Initial version. --- logging.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 logging.h (limited to 'logging.h') 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 + +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 -- cgit v1.2.3