2 * UglyLogging. Slow, yet another wheel reinvented, but enough to make the
3 * rest of our code pretty enough.
13 #include "uglylogging.h"
17 int ugly_init(int maximum_threshold) {
18 max_level = maximum_threshold;
22 int ugly_log(int level, const char *tag, const char *format, ...) {
23 if (level > max_level) {
27 va_start(args, format);
28 time_t mytt = time(NULL);
30 tt = localtime(&mytt);
31 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);
34 fprintf(stderr, "DEBUG %s: ", tag);
37 fprintf(stderr, "INFO %s: ", tag);
40 fprintf(stderr, "WARN %s: ", tag);
43 fprintf(stderr, "ERROR %s: ", tag);
46 fprintf(stderr, "FATAL %s: ", tag);
47 vfprintf(stderr, format, args);
52 fprintf(stderr, "%d %s: ", level, tag);
55 vfprintf(stderr, format, args);