libdaemon 0.14
dlog.h
Go to the documentation of this file.
1#ifndef foodaemonloghfoo
2#define foodaemonloghfoo
3
4/***
5 This file is part of libdaemon.
6
7 Copyright 2003-2008 Lennart Poettering
8
9 libdaemon is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation, either version 2.1 of the
12 License, or (at your option) any later version.
13
14 libdaemon is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with libdaemon. If not, see
21 <http://www.gnu.org/licenses/>.
22***/
23
24#include <syslog.h>
25#include <stdarg.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
45};
46
50
53extern const char* daemon_log_ident;
54
55#if defined(__GNUC__) && ! defined(DAEMON_GCC_PRINTF_ATTR)
56#define DAEMON_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
57#else
59#define DAEMON_GCC_PRINTF_ATTR(a,b)
60#endif
61
66void daemon_log(int prio, const char* t, ...) DAEMON_GCC_PRINTF_ATTR(2,3);
67
72#define DAEMON_LOGV_AVAILABLE 1
73
78void daemon_logv(int prio, const char* t, va_list ap);
79
86char *daemon_ident_from_argv0(char *argv0);
87
92#define DAEMON_SET_VERBOSITY_AVAILABLE 1
93
108void daemon_set_verbosity(int verbosity_prio);
109
110#ifdef __cplusplus
111}
112#endif
113
114#endif
void daemon_set_verbosity(int verbosity_prio)
Setter for the verbosity level of standard output.
void daemon_logv(int prio, const char *t, va_list ap)
Same as daemon_log(), but without variadic arguments.
daemon_log_flags
Specifies where to send the log messages to.
Definition dlog.h:38
@ DAEMON_LOG_SYSLOG
Log messages are written to syslog.
Definition dlog.h:39
@ DAEMON_LOG_STDERR
Log messages are written to STDERR.
Definition dlog.h:40
@ DAEMON_LOG_AUTO
If this is set a daemon_fork() will change this to DAEMON_LOG_SYSLOG in the daemon process.
Definition dlog.h:42
@ DAEMON_LOG_STDOUT
Log messages are written to STDOUT.
Definition dlog.h:41
enum daemon_log_flags daemon_log_use
This variable is used to specify the log target(s) to use.
#define DAEMON_GCC_PRINTF_ATTR(a, b)
A macro for making use of GCCs printf compilation warnings.
Definition dlog.h:59
const char * daemon_log_ident
Specifies the syslog identification, use daemon_ident_from_argv0() to set this to a sensible value or...
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.
char * daemon_ident_from_argv0(char *argv0)
Return a sensible syslog identification for daemon_log_ident generated from argv[0].