2 * log.h - Simple logging framework.
4 * Copyright 2003 Jonathan McDowell <noodles@earth.li>
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #define log_assert(expr) \
27 logthing(LOGTHING_CRITICAL, \
28 "Assertion %s failed in %s, line %d", \
36 * loglevels - levels of severity for a log entry
38 * These provide various different levels of severity for a log entry. In
39 * acesending order they are:
49 * By default the log threshold is set to LOGTHING_NOTICE, meaning
50 * anything with a lower priority won't be output.
63 * initlogthing - initialize the logging module
64 * @appname: The application name to use in the log.
65 * @filename: The filename to log to. NULL means stderr.
67 * This function sets up the logging module ready to log. The appname is
68 * written as part of every log entry and the filename is the file we
69 * should log to. If the appname is NULL then none is written. If the
70 * filename is NULL all output is sent to stderr.
72 int initlogthing(const char *appname, const char *filename);
75 * cleanuplogthing - clean up the logging module
77 * This function cleans up the logging module after use.
79 void cleanuplogthing(void);
82 * setlogthreshold - set the threshold for log output
83 * @loglevel: The minimum log level we should output
85 * Sets the threshold for log output; anything logged with a log level
86 * lower than this will be silently dropped. Returns the old log threshold
89 loglevels setlogthreshold(loglevels loglevel);
92 * logthing - output a log entry
93 * @loglevel: The level of the log.
94 * @format: A format string, followed by any parameters required.
96 * This function outputs a log entry. A leading time/date stamp and a
97 * trailing newline are automatically added. The loglevel is compared to
98 * the current log threshold and if equal or above the log entry is
99 * output. The format parameter is of the same nature as that used in
102 int logthing(loglevels loglevel, const char *format, ...);
104 #endif /* __LOG_H__ */