Added show current logging level in usage output

Fortune for naka's current commit: Small curse − 小凶
master
Avril 3 years ago
parent 033ec9e902
commit 63513504be
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -20,20 +20,24 @@ static const char* _compdate_readable()
{ {
static const time_t comp = PROG_COMPILED_TIMESTAMP; static const time_t comp = PROG_COMPILED_TIMESTAMP;
static _Thread_local char date[40] = {0}; #define DATE_MAX 20
debug_assert(sizeof(date) == 40); static _Thread_local char date[DATE_MAX] = {0};
debug_assert(sizeof(date) == DATE_MAX);
struct tm* time = gmtime(&comp); struct tm* time = gmtime(&comp);
if(!date[0]) { if(!date[0]) {
usize w = strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", time); usize w = strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", time);
DBG(ifU(!w || w>=DATE_MAX) FATAL("Increase DATE_MAX, %lu is too low (strftime(): %lu)", DATE_MAX, w));
TRACE("size of hr time: %lu / %lu", w, sizeof(date)); TRACE("size of hr time: %lu / %lu", w, sizeof(date));
} }
return date; return date;
#undef DATE_MAX
} }
static void pi_print_trace_infos(FILE* out) static void pi_print_trace_infos(FILE* out)
{ {
const char* name; const char* name;
enum trace_level cmax = trace_max_level();
for(int i=0;i<(int)_TRACE_LEVEL_NUM;i++) for(int i=0;i<(int)_TRACE_LEVEL_NUM;i++)
{ {
enum trace_level lv = (enum trace_level)i; enum trace_level lv = (enum trace_level)i;
@ -42,7 +46,7 @@ static void pi_print_trace_infos(FILE* out)
debug_assert(AS(lv, int) < AS(_TRACE_LEVEL_NUM, int) && AS(lv, int) >= 0); debug_assert(AS(lv, int) < AS(_TRACE_LEVEL_NUM, int) && AS(lv, int) >= 0);
const char* desc = lv[_trace_level_descriptions]; const char* desc = lv[_trace_level_descriptions];
assert(desc); assert(desc);
fprintf(out, "-> level %d: \"%s\" - %s\n", i, name, desc); fprintf(out, "-> level %d: \"%s\" - %s%s\n", i, name, desc, cmax==lv ? " (currently set)" : "");
} }
} }
enum trace_level def = _TRACE_LEVEL_DEFAULT; enum trace_level def = _TRACE_LEVEL_DEFAULT;

Loading…
Cancel
Save