8662f05f351bdb8870b02c73d05738f4c00a4881
12 * Generic console notifier.
16 notify_fn_default_(int level
, const char * func_name
, const char * fmt
, ...)
18 FILE *f
= (level
<= 1) ? stderr
: stdout
;
19 static const char * const levels
[] = { "FATAL", "ERROR", "INFO", "DEBUG" };
20 const int levels_num
= sizeof levels
/ sizeof *levels
;
25 fputs_unlocked((func_name
&& *func_name
) ? func_name
: "[null]", f
);
26 fputs_unlocked(": --", f
);
28 && level
<= levels_num
) {
29 fputs_unlocked(levels
[level
], f
);
31 fprintf(f
, "%d", level
);
33 fputs_unlocked("-- ", f
);
39 fputc_unlocked('\n', f
);
46 void (* notify_fn
)(int level
, const char *func_name
, const char *msg
, ...) __attribute__((format(printf
, 3, 4))) = notify_fn_default_
;
49 notify_fn_set(void (* fn
)(int level
, const char *func_name
, const char *fmt
, ...))