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
|
2023-03-31 06:32:32 +00:00
|
|
|
|
2023-02-06 07:10:02 +00:00
|
|
|
#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 {
|
2023-04-25 01:17:08 +00:00
|
|
|
trace = ZLOG_LEVEL_TRACE,
|
|
|
|
debug = ZLOG_LEVEL_DEBUG,
|
|
|
|
info = ZLOG_LEVEL_INFO,
|
2023-02-20 02:59:47 +00:00
|
|
|
notice = ZLOG_LEVEL_NOTICE,
|
2023-04-25 01:17:08 +00:00
|
|
|
warn = ZLOG_LEVEL_WARN,
|
|
|
|
error = ZLOG_LEVEL_ERROR,
|
|
|
|
fatal = ZLOG_LEVEL_FATAL
|
2023-02-20 02:59:47 +00:00
|
|
|
} ZLOG_LV;
|
|
|
|
|
|
|
|
#define DEF_ZLOG_MOD(ZLOG_MOD) \
|
2023-05-08 09:52:19 +00:00
|
|
|
ZLOG_MOD(ZLOG_MOD_MAIN, ZLOG_LEVEL_INFO, "MAIN") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_TASK, ZLOG_LEVEL_INFO, "TASK") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_INIT, ZLOG_LEVEL_INFO, "INIT") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_MISC, ZLOG_LEVEL_INFO, "MISC") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_WATCH, ZLOG_LEVEL_INFO, "WATCH") \
|
|
|
|
ZLOG_MO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L_INFO, "DHCP_DB") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_OPENDHCPD, ZLOG_LEVEL_INFO, "ODHCPD")
|
2023-02-20 02:59:47 +00:00
|
|
|
|
|
|
|
#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-03-29 09:02:21 +00:00
|
|
|
#define hzlog_trace(cat, buf, buf_len) \
|
|
|
|
hzlog(cat, __FILE__, sizeof(__FILE__) - 1, __func__, sizeof(__func__) - 1, __LINE__, ZLOG_LEVEL_DEBUG, buf, buf_len)
|
|
|
|
|
2023-04-25 09:06:34 +00:00
|
|
|
#define zlog_trace(cat, format, ...) \
|
|
|
|
zlog(cat, __FILE__, sizeof(__FILE__) - 1, __func__, sizeof(__func__) - 1, __LINE__, ZLOG_LEVEL_TRACE, format, \
|
2023-02-20 02:59:47 +00:00
|
|
|
##__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-03-20 02:47:22 +00:00
|
|
|
printf("\n"); \
|
2023-02-20 02:59:47 +00:00
|
|
|
} \
|
2023-02-06 07:10:02 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
zlog_category_t *zlog_get_mod_cat(ZLOG_MOD_NAME logMod);
|
2023-03-31 06:32:32 +00:00
|
|
|
|
|
|
|
int zlog_verify_level(int level, ZLOG_MOD_NAME logMod);
|
|
|
|
|
|
|
|
const char *zlog_vni_tag_get();
|
|
|
|
|
2023-02-06 07:10:02 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif //VCPE_ZLOG_MODULE_H
|