24 #include <core/threading/mutex.h>
25 #include <logging/console.h>
27 #include <utils/system/console_colors.h>
51 now_s = (struct ::tm *)malloc(
sizeof(struct ::tm));
53 outf_ = fdopen(dup(STDERR_FILENO),
"a");
55 setvbuf(outf_, NULL, _IOLBF, 0);
71 gettimeofday(&now, NULL);
73 localtime_r(&now.tv_sec, now_s);
75 "%s%02d:%02d:%02d.%06ld %s: ",
82 vfprintf(outf_, format, va);
93 gettimeofday(&now, NULL);
95 localtime_r(&now.tv_sec, now_s);
97 "%02d:%02d:%02d.%06ld %s: ",
103 vfprintf(outf_, format, va);
104 fprintf(outf_,
"\n");
114 gettimeofday(&now, NULL);
116 localtime_r(&now.tv_sec, now_s);
118 "%s%02d:%02d:%02d.%06ld %s: ",
125 vfprintf(outf_, format, va);
136 gettimeofday(&now, NULL);
138 localtime_r(&now.tv_sec, now_s);
140 "%s%02d:%02d:%02d.%06ld %s: ",
147 vfprintf(outf_, format, va);
157 va_start(arg, format);
166 va_start(arg, format);
175 va_start(arg, format);
184 va_start(arg, format);
194 gettimeofday(&now, NULL);
196 localtime_r(&now.tv_sec, now_s);
199 "%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
206 fprintf(outf_,
"%s", *i);
218 gettimeofday(&now, NULL);
220 localtime_r(&now.tv_sec, now_s);
223 "%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
229 fprintf(outf_,
"%s", *i);
241 gettimeofday(&now, NULL);
243 localtime_r(&now.tv_sec, now_s);
246 "%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
253 fprintf(outf_,
"%s", *i);
265 gettimeofday(&now, NULL);
267 localtime_r(&now.tv_sec, now_s);
270 "%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
277 fprintf(outf_,
"%s", *i);
288 va_start(arg, format);
297 va_start(arg, format);
306 va_start(arg, format);
315 va_start(arg, format);
325 localtime_r(&t->tv_sec, now_s);
328 "%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
335 fprintf(outf_,
"%s", *i);
347 localtime_r(&t->tv_sec, now_s);
350 "%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
356 fprintf(outf_,
"%s", *i);
368 localtime_r(&t->tv_sec, now_s);
371 "%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
378 fprintf(outf_,
"%s", *i);
390 localtime_r(&t->tv_sec, now_s);
393 "%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
400 fprintf(outf_,
"%s", *i);
412 localtime_r(&t->tv_sec, now_s);
414 "%s%02d:%02d:%02d.%06ld %s: ",
421 vfprintf(outf_, format, va);
432 localtime_r(&t->tv_sec, now_s);
434 "%02d:%02d:%02d.%06ld %s: ",
440 vfprintf(outf_, format, va);
441 fprintf(outf_,
"\n");
451 localtime_r(&t->tv_sec, now_s);
453 "%s%02d:%02d:%02d.%06ld %s: ",
460 vfprintf(outf_, format, va);
471 localtime_r(&t->tv_sec, now_s);
473 "%s%02d:%02d:%02d.%06ld %s: ",
480 vfprintf(outf_, format, va);
virtual void tlog_error(struct timeval *t, const char *component, const char *format,...)
Log error message for specific time.
virtual void vlog_warn(const char *component, const char *format, va_list va)
Log warning message.
virtual void log_error(const char *component, const char *format,...)
Log error message.
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 vtlog_debug(struct timeval *t, const char *component, const char *format, va_list va)
Log debug message for specific time.
virtual void tlog_info(struct timeval *t, const char *component, const char *format,...)
Log informational message for specific time.
virtual void tlog_debug(struct timeval *t, const char *component, const char *format,...)
Log debug message for specific time.
virtual void log_info(const char *component, const char *format,...)
Log informational message.
virtual void vlog_error(const char *component, const char *format, va_list va)
Log error message.
virtual void vlog_debug(const char *component, const char *format, va_list va)
Log debug message.
virtual void vtlog_info(struct timeval *t, const char *component, const char *format, va_list va)
Log informational message for specific time.
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 log_debug(const char *component, const char *format,...)
Log debug message.
virtual ~ConsoleLogger()
Destructor.
virtual void tlog_warn(struct timeval *t, const char *component, const char *format,...)
Log warning message for specific time.
ConsoleLogger(LogLevel log_level=LL_DEBUG)
Constructor.
Message iterator for exceptions.
Base class for exceptions in Fawkes.
iterator begin()
Get iterator for messages.
iterator end()
Get end iterator for messages.
@ LL_INFO
informational output about normal procedures
@ LL_WARN
warning, should be investigated but software still functions, an example is that something was reques...
@ LL_ERROR
error, may be recoverable (software still running) or not (software has to terminate).
@ LL_DEBUG
debug output, relevant only when tracking down problems
LogLevel log_level
Minimum log level.
Mutex mutual exclusion lock.
void lock()
Lock this mutex.
void unlock()
Unlock the mutex.
Fawkes library namespace.
static const char * c_normal
Print normal on console, without colors, depends on console settings.
static const char * c_lightgray
Print light gray on console.
static const char * c_brown
Print brown on console.
static const char * c_red
Print red on console.