diff options
author | Lennart Poettering <lennart@poettering.net> | 2003-07-31 14:18:41 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2003-07-31 14:18:41 +0000 |
commit | e774e8ef3467e81ed502e19b1719b4ab384d0083 (patch) | |
tree | 8eb9ee6196c383347cb2be00ec389d5c177b5d17 /src/dlog.h |
Moved to trunk
git-svn-id: file:///home/lennart/svn/public/libdaemon/trunk@38 153bfa13-eec0-0310-be40-b0cb6a0e1b4b
Diffstat (limited to 'src/dlog.h')
-rw-r--r-- | src/dlog.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/dlog.h b/src/dlog.h new file mode 100644 index 0000000..8edf6b3 --- /dev/null +++ b/src/dlog.h @@ -0,0 +1,63 @@ +#ifndef foodaemonloghfoo +#define foodaemonloghfoo + +/* + * This file is part of libdaemon. + * + * libdaemon is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * libdaemon is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with libdaemon; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include <syslog.h> + + +/** \file + * + * Contains a robust API for logging messages + */ + + +/** Specifies where to send the log messages to + */ +enum daemon_log_flags { + DAEMON_LOG_SYSLOG = 1, /**< Log messages are written to syslog */ + DAEMON_LOG_STDERR = 2, /**< Log messages are written to STDERR */ + DAEMON_LOG_STDOUT = 4, /**< Log messages are written to STDOUT */ + DAEMON_LOG_AUTO = 8 /**< If this is set a daemon_fork() will + change this to DAEMON_LOG_SYSLOG in + the daemon process. */ +}; + +/** This variable is used to specify the log target(s) to use. Defaults to DAEMON_LOG_STDERR|DAEMON_LOG_AUTO */ +extern enum daemon_log_flags daemon_log_use; + +/** Specifies the syslog identification, use daemon_ident_from_argv0() + * to set this to a sensible value or generate your own. */ +extern char* daemon_log_ident; + +/** Log a message using printf format strings using the specified syslog priority + * @param prio The syslog priority (PRIO_xxx constants) + * @param t,... The text message to log + */ +void daemon_log(int prio, const char* t, ...); + +/** 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 + * @param argv0 argv[0] as passed to main() + * @return The identification string + */ +char *daemon_ident_from_argv0(char *argv0); + +#endif |