24 #include <core/threading/mutex.h>
25 #include <logging/console.h>
27 #include <utils/system/console_colors.h>
53 now_s = (struct ::tm *)malloc(
sizeof(struct ::tm));
71 gettimeofday(&now, NULL);
73 localtime_r(&now.tv_sec, now_s);
74 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: ",
c_lightgray, now_s->tm_hour,
75 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
76 vfprintf(stderr, format, va);
88 gettimeofday(&now, NULL);
90 localtime_r(&now.tv_sec, now_s);
91 fprintf(stderr,
"%02d:%02d:%02d.%06ld %s: ", now_s->tm_hour, now_s->tm_min,
92 now_s->tm_sec, (
long)now.tv_usec, component);
93 vfprintf(stderr, format, va);
94 fprintf(stderr,
"\n");
105 gettimeofday(&now, NULL);
107 localtime_r(&now.tv_sec, now_s);
108 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: ",
c_brown, now_s->tm_hour,
109 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
110 vfprintf(stderr, format, va);
122 gettimeofday(&now, NULL);
124 localtime_r(&now.tv_sec, now_s);
125 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: ",
c_red, now_s->tm_hour,
126 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
127 vfprintf(stderr, format, va);
138 va_start(arg, format);
148 va_start(arg, format);
158 va_start(arg, format);
168 va_start(arg, format);
179 gettimeofday(&now, NULL);
181 localtime_r(&now.tv_sec, now_s);
183 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_lightgray, now_s->tm_hour,
184 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
185 fprintf(stderr,
"%s", *i);
198 gettimeofday(&now, NULL);
200 localtime_r(&now.tv_sec, now_s);
202 fprintf(stderr,
"%02d:%02d:%02d.%06ld %s: [EXCEPTION] ", now_s->tm_hour,
203 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
204 fprintf(stderr,
"%s", *i);
217 gettimeofday(&now, NULL);
219 localtime_r(&now.tv_sec, now_s);
221 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_brown, now_s->tm_hour,
222 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
223 fprintf(stderr,
"%s", *i);
236 gettimeofday(&now, NULL);
238 localtime_r(&now.tv_sec, now_s);
240 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_red, now_s->tm_hour,
241 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
242 fprintf(stderr,
"%s", *i);
254 va_start(arg, format);
264 va_start(arg, format);
274 va_start(arg, format);
284 va_start(arg, format);
295 localtime_r(&t->tv_sec, now_s);
297 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_lightgray, now_s->tm_hour,
298 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
299 fprintf(stderr,
"%s", *i);
312 localtime_r(&t->tv_sec, now_s);
314 fprintf(stderr,
"%02d:%02d:%02d.%06ld %s: [EXCEPTION] ", now_s->tm_hour,
315 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
316 fprintf(stderr,
"%s", *i);
329 localtime_r(&t->tv_sec, now_s);
331 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_brown, now_s->tm_hour,
332 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
333 fprintf(stderr,
"%s", *i);
346 localtime_r(&t->tv_sec, now_s);
348 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_red, now_s->tm_hour,
349 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
350 fprintf(stderr,
"%s", *i);
365 localtime_r(&t->tv_sec, now_s);
366 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: ",
c_lightgray, now_s->tm_hour,
367 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
368 vfprintf(stderr, format, va);
380 localtime_r(&t->tv_sec, now_s);
381 fprintf(stderr,
"%02d:%02d:%02d.%06ld %s: ", now_s->tm_hour, now_s->tm_min,
382 now_s->tm_sec, (
long)t->tv_usec, component);
383 vfprintf(stderr, format, va);
384 fprintf(stderr,
"\n");
395 localtime_r(&t->tv_sec, now_s);
396 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: ",
c_brown, now_s->tm_hour,
397 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
398 vfprintf(stderr, format, va);
410 localtime_r(&t->tv_sec, now_s);
411 fprintf(stderr,
"%s%02d:%02d:%02d.%06ld %s: ",
c_red, now_s->tm_hour,
412 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
413 vfprintf(stderr, format, va);
ConsoleLogger(LogLevel log_level=LL_DEBUG)
Constructor.
LogLevel log_level
Minimum log level.
informational output about normal procedures
static const char * c_red
Print red on console.
virtual void log_warn(const char *component, const char *format,...)
Log warning message.
virtual void vlog_info(const char *component, const char *format, va_list va)
Log informational message.
virtual void tlog_error(struct timeval *t, const char *component, const char *format,...)
Log error message for specific time.
Fawkes library namespace.
void unlock()
Unlock the mutex.
virtual void log_debug(const char *component, const char *format,...)
Log debug message.
warning, should be investigated but software still functions, an example is that something was reques...
virtual void tlog_info(struct timeval *t, const char *component, const char *format,...)
Log informational message for specific time.
Message iterator for exceptions.
virtual void log_error(const char *component, const char *format,...)
Log error message.
virtual void tlog_warn(struct timeval *t, const char *component, const char *format,...)
Log warning message for specific time.
error, may be recoverable (software still running) or not (software has to terminate).
iterator end()
Get end iterator for messages.
virtual void log_info(const char *component, const char *format,...)
Log informational message.
Base class for exceptions in Fawkes.
virtual void tlog_debug(struct timeval *t, const char *component, const char *format,...)
Log debug message for specific time.
virtual void vtlog_debug(struct timeval *t, const char *component, const char *format, va_list va)
Log debug message for specific time.
virtual void vlog_error(const char *component, const char *format, va_list va)
Log error message.
virtual void vtlog_info(struct timeval *t, const char *component, const char *format, va_list va)
Log informational message for specific time.
iterator begin()
Get iterator for messages.
virtual void vlog_warn(const char *component, const char *format, va_list va)
Log warning message.
static const char * c_lightgray
Print light gray on console.
debug output, relevant only when tracking down problems
virtual ~ConsoleLogger()
Destructor.
virtual void vtlog_error(struct timeval *t, const char *component, const char *format, va_list va)
Log error message for specific time.
virtual void vtlog_warn(struct timeval *t, const char *component, const char *format, va_list va)
Log warning message for specific time.
virtual void vlog_debug(const char *component, const char *format, va_list va)
Log debug message.
void lock()
Lock this mutex.
Mutex mutual exclusion lock.
static const char * c_normal
Print normal on console, without colors, depends on console settings.
static const char * c_brown
Print brown on console.