2023-02-06 07:10:02 +00:00
|
|
|
//
|
|
|
|
// Created by xajhuang on 2023/2/6.
|
|
|
|
//
|
|
|
|
#include "zlog_module.h"
|
2023-02-07 01:22:54 +00:00
|
|
|
#include "misc.h"
|
|
|
|
|
|
|
|
#define MAX_ZLOG_MOD_LEN (8)
|
2023-02-06 07:10:02 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ZLOG_MOD_NAME logModule;
|
|
|
|
zlog_category_t *pCat;
|
|
|
|
char catName[MAX_ZLOG_MOD_LEN];
|
2023-02-06 08:04:11 +00:00
|
|
|
} ZLOG_MODULE;
|
2023-02-06 07:10:02 +00:00
|
|
|
|
2023-02-07 01:22:54 +00:00
|
|
|
#define GENERATE_ENUM_ARRAY(ENUM, desc) {ENUM, NULL, desc},
|
|
|
|
|
2023-02-06 07:10:02 +00:00
|
|
|
static ZLOG_MODULE g_zlogModule[] = {
|
2023-02-07 01:22:54 +00:00
|
|
|
DEF_ZLOG_MOD(GENERATE_ENUM_ARRAY) {-1, NULL, "UNKNOWN"}
|
2023-02-06 07:10:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
zlog_category_t *zlog_get_mod_cat(ZLOG_MOD_NAME logMod) {
|
2023-02-07 01:22:54 +00:00
|
|
|
if (logMod >= ARRAY_SIZE(g_zlogModule) || logMod < 0) {
|
|
|
|
logMod = ARRAY_SIZE(g_zlogModule) - 1;
|
2023-02-06 07:10:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (g_zlogModule[logMod].pCat == NULL) {
|
|
|
|
g_zlogModule[logMod].pCat = zlog_get_category(g_zlogModule[logMod].catName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return g_zlogModule[logMod].pCat;
|
|
|
|
}
|