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));
55 outf_ = fdopen(dup(STDERR_FILENO),
"a");
73 gettimeofday(&now, NULL);
75 localtime_r(&now.tv_sec, now_s);
76 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: ",
c_lightgray, now_s->tm_hour,
77 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
78 vfprintf(outf_, format, va);
90 gettimeofday(&now, NULL);
92 localtime_r(&now.tv_sec, now_s);
93 fprintf(outf_,
"%02d:%02d:%02d.%06ld %s: ", now_s->tm_hour, now_s->tm_min,
94 now_s->tm_sec, (
long)now.tv_usec, component);
95 vfprintf(outf_, format, va);
107 gettimeofday(&now, NULL);
109 localtime_r(&now.tv_sec, now_s);
110 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: ",
c_brown, now_s->tm_hour,
111 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
112 vfprintf(outf_, format, va);
124 gettimeofday(&now, NULL);
126 localtime_r(&now.tv_sec, now_s);
127 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: ",
c_red, now_s->tm_hour,
128 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
129 vfprintf(outf_, format, va);
140 va_start(arg, format);
150 va_start(arg, format);
160 va_start(arg, format);
170 va_start(arg, format);
181 gettimeofday(&now, NULL);
183 localtime_r(&now.tv_sec, now_s);
185 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_lightgray, now_s->tm_hour,
186 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
187 fprintf(outf_,
"%s", *i);
200 gettimeofday(&now, NULL);
202 localtime_r(&now.tv_sec, now_s);
204 fprintf(outf_,
"%02d:%02d:%02d.%06ld %s: [EXCEPTION] ", now_s->tm_hour,
205 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
206 fprintf(outf_,
"%s", *i);
219 gettimeofday(&now, NULL);
221 localtime_r(&now.tv_sec, now_s);
223 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_brown, now_s->tm_hour,
224 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
225 fprintf(outf_,
"%s", *i);
238 gettimeofday(&now, NULL);
240 localtime_r(&now.tv_sec, now_s);
242 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_red, now_s->tm_hour,
243 now_s->tm_min, now_s->tm_sec, (
long)now.tv_usec, component);
244 fprintf(outf_,
"%s", *i);
256 va_start(arg, format);
266 va_start(arg, format);
276 va_start(arg, format);
286 va_start(arg, format);
297 localtime_r(&t->tv_sec, now_s);
299 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_lightgray, now_s->tm_hour,
300 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
301 fprintf(outf_,
"%s", *i);
314 localtime_r(&t->tv_sec, now_s);
316 fprintf(outf_,
"%02d:%02d:%02d.%06ld %s: [EXCEPTION] ", now_s->tm_hour,
317 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
318 fprintf(outf_,
"%s", *i);
331 localtime_r(&t->tv_sec, now_s);
333 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_brown, now_s->tm_hour,
334 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
335 fprintf(outf_,
"%s", *i);
348 localtime_r(&t->tv_sec, now_s);
350 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: [EXCEPTION] ",
c_red, now_s->tm_hour,
351 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
352 fprintf(outf_,
"%s", *i);
367 localtime_r(&t->tv_sec, now_s);
368 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: ",
c_lightgray, now_s->tm_hour,
369 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
370 vfprintf(outf_, format, va);
382 localtime_r(&t->tv_sec, now_s);
383 fprintf(outf_,
"%02d:%02d:%02d.%06ld %s: ", now_s->tm_hour, now_s->tm_min,
384 now_s->tm_sec, (
long)t->tv_usec, component);
385 vfprintf(outf_, format, va);
386 fprintf(outf_,
"\n");
397 localtime_r(&t->tv_sec, now_s);
398 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: ",
c_brown, now_s->tm_hour,
399 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
400 vfprintf(outf_, format, va);
412 localtime_r(&t->tv_sec, now_s);
413 fprintf(outf_,
"%s%02d:%02d:%02d.%06ld %s: ",
c_red, now_s->tm_hour,
414 now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, component);
415 vfprintf(outf_, 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.