2 * UglyLogging. Slow, yet another wheel reinvented, but enough to make the
3 * rest of our code pretty enough.
12 #include "stlink/logging.h"
16 int ugly_init(int maximum_threshold) {
17 max_level = maximum_threshold;
21 int ugly_log(int level, const char *tag, const char *format, ...) {
22 if (level > max_level) {
26 va_start(args, format);
27 time_t mytt = time(NULL);
29 tt = localtime(&mytt);
30 fprintf(stderr, "%d-%02d-%02dT%02d:%02d:%02d ", tt->tm_year + 1900, tt->tm_mon + 1, tt->tm_mday, tt->tm_hour, tt->tm_min, tt->tm_sec);
33 fprintf(stderr, "DEBUG %s: ", tag);
36 fprintf(stderr, "INFO %s: ", tag);
39 fprintf(stderr, "WARN %s: ", tag);
42 fprintf(stderr, "ERROR %s: ", tag);
45 fprintf(stderr, "FATAL %s: ", tag);
46 vfprintf(stderr, format, args);
51 fprintf(stderr, "%d %s: ", level, tag);
54 vfprintf(stderr, format, args);