summaryrefslogtreecommitdiff
path: root/logging.h
diff options
context:
space:
mode:
authorKeuin <[email protected]>2021-12-28 05:37:54 +0800
committerKeuin <[email protected]>2021-12-28 05:37:54 +0800
commit94d7588c2045cbe76ec0287a5e92f1b4123d996f (patch)
tree651b547091858b1fbf536bf7b5209a90c32b1281 /logging.h
Initial version.
Diffstat (limited to 'logging.h')
-rw-r--r--logging.h25
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