24 #include <core/threading/mutex.h>
25 #include <logging/syslog.h>
48 now_s = (struct ::tm *)malloc(
sizeof(struct ::tm));
51 openlog(
"Fawkes", LOG_CONS | LOG_NDELAY, LOG_USER);
62 now_s = (struct ::tm *)malloc(
sizeof(struct ::tm));
66 openlog(
"Fawkes", LOG_CONS | LOG_NDELAY, LOG_USER);
68 __ident = strdup(ident);
69 openlog(__ident, LOG_CONS | LOG_NDELAY, LOG_USER);
80 if (__ident) free(__ident);
91 if (vasprintf(&message, format, va) != -1) {
92 syslog(LOG_DEBUG,
"%s: %s", component, message);
95 vsyslog(LOG_DEBUG, format, va);
108 if (vasprintf(&message, format, va) != -1) {
109 syslog(LOG_INFO,
"%s: %s", component, message);
112 vsyslog(LOG_INFO, format, va);
125 if (vasprintf(&message, format, va) != -1) {
126 syslog(LOG_WARNING,
"%s: %s", component, message);
129 vsyslog(LOG_WARNING, format, va);
142 if (vasprintf(&message, format, va) != -1) {
143 syslog(LOG_ERR,
"%s: %s", component, message);
146 vsyslog(LOG_ERR, format, va);
157 va_start(arg, format);
167 va_start(arg, format);
177 va_start(arg, format);
187 va_start(arg, format);
199 syslog(LOG_DEBUG,
"%s: [EXC] %s", component, *i);
212 syslog(LOG_INFO,
"%s: [EXC] %s", component, *i);
225 syslog(LOG_WARNING,
"%s: [EXC] %s", component, *i);
238 syslog(LOG_ERR,
"%s: [EXC] %s", component, *i);
249 va_start(arg, format);
259 va_start(arg, format);
269 va_start(arg, format);
279 va_start(arg, format);
290 localtime_r(&t->tv_sec, now_s);
292 syslog(LOG_DEBUG,
"%s @ %02d:%02d:%02d.%06ld: [EXC] %s", component,
293 now_s->tm_hour, now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, *i);
305 localtime_r(&t->tv_sec, now_s);
307 syslog(LOG_INFO,
"%s @ %02d:%02d:%02d.%06ld: [EXC] %s", component,
308 now_s->tm_hour, now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, *i);
320 localtime_r(&t->tv_sec, now_s);
322 syslog(LOG_WARNING,
"%s @ %02d:%02d:%02d.%06ld: [EXC] %s", component,
323 now_s->tm_hour, now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, *i);
335 localtime_r(&t->tv_sec, now_s);
337 syslog(LOG_ERR,
"%s @ %02d:%02d:%02d.%06ld: [EXC] %s", component,
338 now_s->tm_hour, now_s->tm_min, now_s->tm_sec, (
long)t->tv_usec, *i);
349 const char *format, va_list va)
353 localtime_r(&t->tv_sec, now_s);
355 if (vasprintf(&message, format, va) != -1) {
356 syslog(LOG_DEBUG,
"%s @ %02d:%02d:%02d.%06ld: %s", component,
357 now_s->tm_hour, now_s->tm_min, now_s->tm_sec,
358 (
long)t->tv_usec, message);
361 vsyslog(LOG_DEBUG, format, va);
373 localtime_r(&t->tv_sec, now_s);
375 if (vasprintf(&message, format, va) != -1) {
376 syslog(LOG_INFO,
"%s @ %02d:%02d:%02d.%06ld: %s", component,
377 now_s->tm_hour, now_s->tm_min, now_s->tm_sec,
378 (
long)t->tv_usec, message);
381 vsyslog(LOG_INFO, format, va);
393 localtime_r(&t->tv_sec, now_s);
395 if (vasprintf(&message, format, va) != -1) {
396 syslog(LOG_WARNING,
"%s @ %02d:%02d:%02d.%06ld: %s", component,
397 now_s->tm_hour, now_s->tm_min, now_s->tm_sec,
398 (
long)t->tv_usec, message);
401 vsyslog(LOG_WARNING, format, va);
413 localtime_r(&t->tv_sec, now_s);
415 if (vasprintf(&message, format, va) != -1) {
416 syslog(LOG_ERR,
"%s @ %02d:%02d:%02d.%06ld: %s", component,
417 now_s->tm_hour, now_s->tm_min, now_s->tm_sec,
418 (
long)t->tv_usec, message);
421 vsyslog(LOG_ERR, format, va);
virtual void log_warn(const char *component, const char *format,...)
Log warning message.
virtual void log_debug(const char *component, const char *format,...)
Log debug message.
virtual void vtlog_error(struct timeval *t, const char *component, const char *format, va_list va)
Log error message for specific time.
LogLevel log_level
Minimum log level.
informational output about normal procedures
virtual void vlog_warn(const char *component, const char *format, va_list va)
Log warning message.
virtual void vtlog_warn(struct timeval *t, const char *component, const char *format, va_list va)
Log warning message for specific time.
virtual void tlog_info(struct timeval *t, const char *component, const char *format,...)
Log informational message for specific time.
void unlock()
Unlock the mutex.
warning, should be investigated but software still functions, an example is that something was reques...
virtual void vtlog_debug(struct timeval *t, const char *component, const char *format, va_list va)
Log debug message for specific time.
Message iterator for exceptions.
SyslogLogger(LogLevel log_level=LL_DEBUG)
Constructor.
virtual void vlog_info(const char *component, const char *format, va_list va)
Log informational 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 vlog_error(const char *component, const char *format, va_list va)
Log error message.
virtual ~SyslogLogger()
Destructor.
Base class for exceptions in Fawkes.
virtual void vlog_debug(const char *component, const char *format, va_list va)
Log debug message.
virtual void log_error(const char *component, const char *format,...)
Log error message.
iterator begin()
Get iterator for messages.
debug output, relevant only when tracking down problems
virtual void tlog_debug(struct timeval *t, const char *component, const char *format,...)
Log debug message for specific time.
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_error(struct timeval *t, const char *component, const char *format,...)
Log error message for specific time.
void lock()
Lock this mutex.
virtual void log_info(const char *component, const char *format,...)
Log informational message.
Mutex mutual exclusion lock.