Added descriptions for logging levels

Fortune for naka's current commit: Half blessing − 半吉
master
Avril 3 years ago
parent 7295733087
commit 4b6cc7034b
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -31,5 +31,7 @@ int trace_init();
const char* trace_name_of(enum trace_level lv); const char* trace_name_of(enum trace_level lv);
extern const char* const _TRACE_CONTROL_ENV_NAME; extern const char* const _TRACE_CONTROL_ENV_NAME;
extern const char* const _trace_level_descriptions[_TRACE_LEVEL_NUM];
#endif /* _TRACE_H */ #endif /* _TRACE_H */

@ -23,7 +23,10 @@ static void pi_print_trace_infos(FILE* out)
enum trace_level lv = (enum trace_level)i; enum trace_level lv = (enum trace_level)i;
name = trace_name_of(lv); name = trace_name_of(lv);
if(name) { if(name) {
fprintf(out, "-> level %d: \"%s\"\n", i, name); debug_assert(AS(lv, int) < AS(_TRACE_LEVEL_NUM, int) && AS(lv, int) >= 0);
const char* desc = lv[_trace_level_descriptions];
assert(desc);
fprintf(out, "-> level %d: \"%s\" - %s\n", i, name, desc);
} }
} }
enum trace_level def = _TRACE_LEVEL_DEFAULT; enum trace_level def = _TRACE_LEVEL_DEFAULT;

@ -27,6 +27,14 @@ const struct {const char* const name; const enum trace_level level; } _trace_lev
}; };
#define _trace_level_names_n (sizeof(_trace_level_names) / sizeof(_trace_level_names[0])) #define _trace_level_names_n (sizeof(_trace_level_names) / sizeof(_trace_level_names[0]))
const char* const _trace_level_descriptions[_TRACE_LEVEL_NUM] = {
"All trace messages regarding internals, only useful for debugging",
"Information messages regarding processes, recommended level",
"Only show warnings",
"Only show errors",
"Only show fatal (aborting) errors",
};
static bool _trace_lookup(const char*pIN name, enum trace_level *pOUT olevel) static bool _trace_lookup(const char*pIN name, enum trace_level *pOUT olevel)
{ {

Loading…
Cancel
Save