1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
|