2023-02-06 07:10:02 +00:00
|
|
|
//
|
|
|
|
// Created by xajhuang on 2023/2/6.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef VCPE_ZLOG_MODULE_H
|
|
|
|
#define VCPE_ZLOG_MODULE_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
#include <zlog.h>
|
|
|
|
|
2023-02-20 02:59:47 +00:00
|
|
|
enum {
|
|
|
|
ZLOG_LEVEL_TRACE = 10,
|
|
|
|
};
|
2023-02-07 01:22:54 +00:00
|
|
|
|
2023-02-20 02:59:47 +00:00
|
|
|
typedef enum {
|
|
|
|
trace = ZLOG_LEVEL_TRACE,
|
|
|
|
debug = ZLOG_LEVEL_DEBUG,
|
|
|
|
info = ZLOG_LEVEL_INFO,
|
|
|
|
notice = ZLOG_LEVEL_NOTICE,
|
|
|
|
warn = ZLOG_LEVEL_WARN,
|
|
|
|
error = ZLOG_LEVEL_ERROR,
|
|
|
|
fatal = ZLOG_LEVEL_FATAL
|
|
|
|
} ZLOG_LV;
|
|
|
|
|
|
|
|
#define DEF_ZLOG_MOD(ZLOG_MOD) \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_MAIN, ZLOG_LEVEL_DEBUG, "MAIN") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_TASK, ZLOG_LEVEL_DEBUG, "TASK") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_INIT, ZLOG_LEVEL_DEBUG, "INIT") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_MISC, ZLOG_LEVEL_DEBUG, "MISC") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_WATCH, ZLOG_LEVEL_DEBUG, "WATCH") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_CONFIG, ZLOG_LEVEL_DEBUG, "CONFIG") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_NET, ZLOG_LEVEL_DEBUG, "NET") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_CRYPTO, ZLOG_LEVEL_DEBUG, "CRYPTO") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_MQ, ZLOG_LEVEL_DEBUG, "MQ") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_PROTO, ZLOG_LEVEL_DEBUG, "PROTO") \
|
2023-02-27 06:10:36 +00:00
|
|
|
ZLOG_MOD(ZLOG_MOD_HTTPD, ZLOG_LEVEL_INFO, "HTTPD") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_JSCHEM, ZLOG_LEVEL_INFO, "JSCHEM") \
|
2023-02-20 02:59:47 +00:00
|
|
|
ZLOG_MOD(ZLOG_MOD_USER, ZLOG_LEVEL_DEBUG, "USER") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_PPPOE, ZLOG_LEVEL_DEBUG, "PPPOE") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_VXLAN, ZLOG_LEVEL_DEBUG, "VXLAN") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_LWIP, ZLOG_LEVEL_DEBUG, "LWIP") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_OPENDHCPD, ZLOG_LEVEL_DEBUG, "DHCPD")
|
|
|
|
|
|
|
|
#define GENERATE_ZLOG_MOD_ENUM(ENUM, lv, x) ENUM,
|
2023-02-06 07:10:02 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2023-02-07 01:22:54 +00:00
|
|
|
DEF_ZLOG_MOD(GENERATE_ZLOG_MOD_ENUM)
|
2023-02-06 07:10:02 +00:00
|
|
|
} ZLOG_MOD_NAME;
|
|
|
|
|
2023-02-20 02:59:47 +00:00
|
|
|
#define zlog_trace(cat, format, ...) \
|
|
|
|
zlog(cat, \
|
|
|
|
__FILE__, \
|
|
|
|
sizeof(__FILE__) - 1, \
|
|
|
|
__func__, \
|
|
|
|
sizeof(__func__) - 1, \
|
|
|
|
__LINE__, \
|
|
|
|
ZLOG_LEVEL_TRACE, \
|
|
|
|
format, \
|
|
|
|
##__VA_ARGS__)
|
2023-02-07 01:22:54 +00:00
|
|
|
|
2023-02-07 01:55:50 +00:00
|
|
|
#define LOG_MSG(level, format, ...) LOG_MOD(level, ZLOG_MOD_MAIN, format, ##__VA_ARGS__)
|
|
|
|
#define LOG_MSG_HEX(level, format, ...) LOG_MOD_HEX(level, ZLOG_MOD_MAIN, format, ##__VA_ARGS__)
|
2023-02-06 08:04:11 +00:00
|
|
|
|
2023-02-20 02:59:47 +00:00
|
|
|
#define LOG_MOD(level, mod, format, ...) \
|
|
|
|
do { \
|
|
|
|
if (zlog_verify_level(level, mod)) { \
|
2023-03-03 07:08:35 +00:00
|
|
|
if (zlog_vni_tag_get()) { \
|
|
|
|
zlog_put_mdc("vni", zlog_vni_tag_get()); \
|
|
|
|
} \
|
2023-02-20 02:59:47 +00:00
|
|
|
zlog_##level(zlog_get_mod_cat((mod)), format, ##__VA_ARGS__); \
|
|
|
|
} \
|
2023-02-06 07:10:02 +00:00
|
|
|
} while (0)
|
|
|
|
|
2023-02-20 02:59:47 +00:00
|
|
|
#define LOG_MOD_HEX(level, mod, format, ...) \
|
|
|
|
do { \
|
|
|
|
if (zlog_verify_level(level, mod)) { \
|
2023-03-03 07:08:35 +00:00
|
|
|
if (zlog_vni_tag_get()) { \
|
|
|
|
zlog_put_mdc("vni", zlog_vni_tag_get()); \
|
|
|
|
} \
|
2023-02-20 02:59:47 +00:00
|
|
|
hzlog_##level(zlog_get_mod_cat((mod)), format, ##__VA_ARGS__); \
|
|
|
|
} \
|
2023-02-06 07:10:02 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
zlog_category_t *zlog_get_mod_cat(ZLOG_MOD_NAME logMod);
|
2023-02-20 02:59:47 +00:00
|
|
|
int zlog_verify_level(int level, ZLOG_MOD_NAME logMod);
|
2023-03-03 07:08:35 +00:00
|
|
|
const char *zlog_vni_tag_get();
|
2023-02-06 07:10:02 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif //VCPE_ZLOG_MODULE_H
|