vcpe/srcs/libs/include/zlog_module.h

68 lines
2.0 KiB
C
Raw Normal View History

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>
#define MAX_ZLOG_MOD_LEN (8)
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;
#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)
#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