63 lines
1.7 KiB
C
63 lines
1.7 KiB
C
//
|
|
// 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, mod, format, ...) \
|
|
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_MSG_HEX(level, mod, format, ...) \
|
|
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
|