24 #include <core/threading/mutex.h>
25 #include <logging/syslog.h>
26 #include <sys/syslog.h>
48 now_s = (struct ::tm *)malloc(
sizeof(struct ::tm));
51 openlog(
"Fawkes", LOG_CONS | LOG_NDELAY, LOG_USER);
60 now_s = (struct ::tm *)malloc(
sizeof(struct ::tm));
64 openlog(
"Fawkes", LOG_CONS | LOG_NDELAY, LOG_USER);
66 ident_ = strdup(ident);
67 openlog(ident_, LOG_CONS | LOG_NDELAY, LOG_USER);
88 if (vasprintf(&message, format, va) != -1) {
89 syslog(LOG_DEBUG,
"%s: %s", component, message);
92 vsyslog(LOG_DEBUG, format, va);
104 if (vasprintf(&message, format, va) != -1) {
105 syslog(LOG_INFO,
"%s: %s", component, message);
108 vsyslog(LOG_INFO, format, va);
120 if (vasprintf(&message, format, va) != -1) {
121 syslog(LOG_WARNING,
"%s: %s", component, message);
124 vsyslog(LOG_WARNING, format, va);
136 if (vasprintf(&message, format, va) != -1) {
137 syslog(LOG_ERR,
"%s: %s", component, message);
140 vsyslog(LOG_ERR, format, va);
150 va_start(arg, format);
159 va_start(arg, format);
168 va_start(arg, format);
177 va_start(arg, format);
188 syslog(LOG_DEBUG,
"%s: [EXC] %s", component, *i);
200 syslog(LOG_INFO,
"%s: [EXC] %s", component, *i);
212 syslog(LOG_WARNING,
"%s: [EXC] %s", component, *i);
224 syslog(LOG_ERR,
"%s: [EXC] %s", component, *i);
234 va_start(arg, format);
243 va_start(arg, format);
252 va_start(arg, format);
261 va_start(arg, format);
271 localtime_r(&t->tv_sec, now_s);
274 "%s @ %02d:%02d:%02d.%06ld: [EXC] %s",
291 localtime_r(&t->tv_sec, now_s);
294 "%s @ %02d:%02d:%02d.%06ld: [EXC] %s",
311 localtime_r(&t->tv_sec, now_s);
314 "%s @ %02d:%02d:%02d.%06ld: [EXC] %s",
331 localtime_r(&t->tv_sec, now_s);
334 "%s @ %02d:%02d:%02d.%06ld: [EXC] %s",
351 localtime_r(&t->tv_sec, now_s);
353 if (vasprintf(&message, format, va) != -1) {
355 "%s @ %02d:%02d:%02d.%06ld: %s",
364 vsyslog(LOG_DEBUG, format, va);
375 localtime_r(&t->tv_sec, now_s);
377 if (vasprintf(&message, format, va) != -1) {
379 "%s @ %02d:%02d:%02d.%06ld: %s",
388 vsyslog(LOG_INFO, format, va);
399 localtime_r(&t->tv_sec, now_s);
401 if (vasprintf(&message, format, va) != -1) {
403 "%s @ %02d:%02d:%02d.%06ld: %s",
412 vsyslog(LOG_WARNING, format, va);
423 localtime_r(&t->tv_sec, now_s);
425 if (vasprintf(&message, format, va) != -1) {
427 "%s @ %02d:%02d:%02d.%06ld: %s",
436 vsyslog(LOG_ERR, format, va);
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.
SyslogLogger(LogLevel log_level=LL_DEBUG)
Constructor.
virtual void vtlog_info(struct timeval *t, const char *component, const char *format, va_list va)
Log informational message for specific time.
virtual void tlog_warn(struct timeval *t, const char *component, const char *format,...)
Log warning message for specific time.
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 log_info(const char *component, const char *format,...)
Log informational message.
virtual void vlog_warn(const char *component, const char *format, va_list va)
Log warning 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 vtlog_warn(struct timeval *t, const char *component, const char *format, va_list va)
Log warning message for specific time.
virtual void log_error(const char *component, const char *format,...)
Log error message.
virtual void tlog_error(struct timeval *t, const char *component, const char *format,...)
Log error 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 log_debug(const char *component, const char *format,...)
Log debug message.
virtual void log_warn(const char *component, const char *format,...)
Log warning message.
virtual void vtlog_error(struct timeval *t, const char *component, const char *format, va_list va)
Log error message for specific time.
virtual void vlog_info(const char *component, const char *format, va_list va)
Log informational message.
virtual ~SyslogLogger()
Destructor.
virtual void tlog_debug(struct timeval *t, const char *component, const char *format,...)
Log debug message for specific time.
Fawkes library namespace.