Contains a robust API for logging messages. More...
#include <syslog.h>
#include <stdarg.h>
Go to the source code of this file.
Defines | |
#define | DAEMON_GCC_PRINTF_ATTR(a, b) |
A macro for making use of GCCs printf compilation warnings. | |
#define | DAEMON_LOGV_AVAILABLE 1 |
This variable is defined to 1 iff daemon_logv() is supported. | |
#define | DAEMON_SET_VERBOSITY_AVAILABLE 1 |
This variable is defined to 1 iff daemon_set_verbosity() is available. | |
Enumerations | |
enum | daemon_log_flags { DAEMON_LOG_SYSLOG = 1, DAEMON_LOG_STDERR = 2, DAEMON_LOG_STDOUT = 4, DAEMON_LOG_AUTO = 8 } |
Specifies where to send the log messages to. More... | |
Functions | |
void | daemon_log (int prio, const char *t,...) DAEMON_GCC_PRINTF_ATTR(2 |
Log a message using printf format strings using the specified syslog priority. | |
void | daemon_logv (int prio, const char *t, va_list ap) |
Same as daemon_log(), but without variadic arguments. | |
char * | daemon_ident_from_argv0 (char *argv0) |
Return a sensible syslog identification for daemon_log_ident generated from argv[0]. | |
void | daemon_set_verbosity (int verbosity_prio) |
Setter for the verbosity level of standard output. | |
Variables | |
enum daemon_log_flags | daemon_log_use |
This variable is used to specify the log target(s) to use. | |
const char * | daemon_log_ident |
Specifies the syslog identification, use daemon_ident_from_argv0() to set this to a sensible value or generate your own. |
Contains a robust API for logging messages.
Definition in file dlog.h.
#define DAEMON_GCC_PRINTF_ATTR | ( | a, | |||
b | ) |
#define DAEMON_LOGV_AVAILABLE 1 |
#define DAEMON_SET_VERBOSITY_AVAILABLE 1 |
This variable is defined to 1 iff daemon_set_verbosity() is available.
enum daemon_log_flags |
Specifies where to send the log messages to.
The global variable daemon_log_use takes values of this type.
DAEMON_LOG_SYSLOG |
Log messages are written to syslog. |
DAEMON_LOG_STDERR |
Log messages are written to STDERR. |
DAEMON_LOG_STDOUT |
Log messages are written to STDOUT. |
DAEMON_LOG_AUTO |
If this is set a daemon_fork() will change this to DAEMON_LOG_SYSLOG in the daemon process. |
char* daemon_ident_from_argv0 | ( | char * | argv0 | ) |
Return a sensible syslog identification for daemon_log_ident generated from argv[0].
This will return a pointer to the file name of argv[0], i.e. strrchr(argv[0], '\')+1
argv0 | argv[0] as passed to main() |
void daemon_log | ( | int | prio, | |
const char * | t, | |||
... | ||||
) |
Log a message using printf format strings using the specified syslog priority.
prio | The syslog priority (PRIO_xxx constants) | |
t,... | The text message to log |
void daemon_logv | ( | int | prio, | |
const char * | t, | |||
va_list | ap | |||
) |
void daemon_set_verbosity | ( | int | verbosity_prio | ) |
Setter for the verbosity level of standard output.
verbosity_prio | Minimum priority level for messages to output on standard output/error |
Allows to decide which messages to output on standard output/error streams. All messages are logged to syslog and this setting does not influence that.
The default value is LOG_WARNING.
const char* daemon_log_ident |
Specifies the syslog identification, use daemon_ident_from_argv0() to set this to a sensible value or generate your own.
This variable is used to specify the log target(s) to use.
Defaults to DAEMON_LOG_STDERR|DAEMON_LOG_AUTO