/*
* This file is part of DisOrder.
- * Copyright (C) 2004-2008 Richard Kettlewell
+ * Copyright (C) 2004-9, 2013 Richard Kettlewell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*/
/** @file lib/log.c @brief Errors and logging
*
- * All messages are initially emitted by one of the four functions below.
- * debug() is generally invoked via D() so that mostly you just do a test
- * rather than a complete subroutine call.
+ * All messages are initially emitted by one of the four functions
+ * below. disorder_debug() is generally invoked via D() so that
+ * mostly you just do a test rather than a complete subroutine call.
*
* Messages are dispatched via @ref log_default. This defaults to @ref
* log_stderr. daemonize() will turn off @ref log_stderr and use @ref
* log_syslog instead.
*
- * fatal() will call exitfn() with a nonzero status. The default value is
- * exit(), but it should be set to _exit() anywhere but the 'main line' of the
- * program, to guarantee that exit() gets called at most once.
+ * disorder_fatal() will call exitfn() with a nonzero status. The
+ * default value is exit(), but it should be set to _exit() anywhere
+ * but the 'main line' of the program, to guarantee that exit() gets
+ * called at most once.
*/
#define NO_MEMORY_ALLOCATION
#include "common.h"
#include <errno.h>
-#include <syslog.h>
-#include <sys/time.h>
+#include <sys/types.h>
+#if HAVE_SYSLOG_H
+# include <syslog.h>
+#endif
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NETDB_H
+# include <netdb.h>
+#endif
#include <time.h>
#include "log.h"
fputc('\n', fp);
}
+#if HAVE_SYSLOG_H
/** @brief Log to syslog */
static void logsyslog(int pri, const char *msg,
void attribute((unused)) *user) {
else
syslog(pri, "%s:%d: %s", debug_filename, debug_lineno, msg);
}
+#endif
/** @brief Log output that writes to @c stderr */
struct log_output log_stderr = { logfp, 0 };
+#if HAVE_SYSLOG_H
/** @brief Log output that sends to syslog */
struct log_output log_syslog = { logsyslog, 0 };
+#endif
/** @brief Format and log a message */
static void vlogger(int pri, const char *fmt, va_list ap) {