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-07 01:22:54 +00:00
|
|
|
#define DEF_ZLOG_MOD(ZLOG_MOD) \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_MAIN, "MAIN") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_TASK, "TASK") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_INIT, "INIT") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_MISC, "MISC") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_CONFIG, "CONFIG") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_NET, "NET") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_CRYPTO, "CRYPTO") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_MQ, "MQ") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_PROTO, "PROTO") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_HTTPD, "HTTPD") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_USER, "USER") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_PPPOE, "PPPOE") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_VXLAN, "VXLAN") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_LWIP, "LWIP") \
|
|
|
|
ZLOG_MOD(ZLOG_MOD_OPENDHCPD, "DHCPD")
|
|
|
|
|
|
|
|
#define GENERATE_ZLOG_MOD_ENUM(ENUM, 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-07 01:22:54 +00:00
|
|
|
//typedef enum {
|
|
|
|
// ZLOG_MOD_MAIN,
|
|
|
|
// ZLOG_MOD_TASK,
|
|
|
|
// ZLOG_MOD_INIT,
|
|
|
|
// ZLOG_MOD_MISC,
|
|
|
|
// ZLOG_MOD_CONFIG,
|
|
|
|
// ZLOG_MOD_NET,
|
|
|
|
// ZLOG_MOD_CRYPTO,
|
|
|
|
// ZLOG_MOD_MQ,
|
|
|
|
// ZLOG_MOD_PROTO,
|
|
|
|
// ZLOG_MOD_HTTPD,
|
|
|
|
//#ifdef USED_LWIP
|
|
|
|
// ZLOG_MOD_USER,
|
|
|
|
// ZLOG_MOD_PPPOE,
|
|
|
|
// ZLOG_MOD_VXLAN,
|
|
|
|
// ZLOG_MOD_LWIP,
|
|
|
|
//#endif
|
|
|
|
// ZLOG_MOD_OPENDHCPD,
|
|
|
|
// ZLOG_MOD_MAX,
|
|
|
|
//} ZLOG_MOD_NAME;
|
|
|
|
|
2023-02-06 08:04:11 +00:00
|
|
|
#define LOG_MSG(level, format, ...) \
|
|
|
|
do { \
|
|
|
|
zlog_##level(zlog_get_mod_cat(ZLOG_MOD_MAIN), format, ##__VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define LOG_MOD(level, mod, format, ...) \
|
2023-02-06 07:10:02 +00:00
|
|
|
do { \
|
|
|
|
zlog_category_t *cat; \
|
|
|
|
if ((cat = zlog_get_mod_cat((mod))) == NULL) { \
|
|
|
|
printf("Unsupport log mod %d\n", mod); \
|
|
|
|
break; \
|
|
|
|
} else { \
|
|
|
|
zlog_##level((cat), format, ##__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2023-02-06 08:04:11 +00:00
|
|
|
#define LOG_MOD_HEX(level, mod, format, ...) \
|
2023-02-06 07:10:02 +00:00
|
|
|
do { \
|
|
|
|
zlog_category_t *cat; \
|
|
|
|
if ((cat = zlog_get_mod_cat((mod))) == NULL) { \
|
|
|
|
printf("Unsupport log mod %d\n", mod); \
|
|
|
|
break; \
|
|
|
|
} else { \
|
|
|
|
hzlog_##level((cat), format, ##__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
zlog_category_t *zlog_get_mod_cat(ZLOG_MOD_NAME logMod);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif //VCPE_ZLOG_MODULE_H
|