2 * log.h - Simple logging framework.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2003 Project Purple
14 #define log_assert(expr) \
16 logthing(LOGTHING_CRITICAL, \
17 "Assertion %s failed in %s, line %d", \
25 * loglevels - levels of severity for a log entry
27 * These provide various different levels of severity for a log entry. In
28 * acesending order they are:
38 * By default the log threshold is set to LOGTHING_NOTICE, meaning
39 * anything with a lower priority won't be output.
52 * initlogthing - initialize the logging module
53 * @appname: The application name to use in the log.
54 * @filename: The filename to log to. NULL means stderr.
56 * This function sets up the logging module ready to log. The appname is
57 * written as part of every log entry and the filename is the file we
58 * should log to. If the appname is NULL then none is written. If the
59 * filename is NULL all output is sent to stderr.
61 int initlogthing(const char *appname, const char *filename);
64 * cleanuplogthing - clean up the logging module
66 * This function cleans up the logging module after use.
68 void cleanuplogthing(void);
71 * setlogthreshold - set the threshold for log output
72 * @loglevel: The minimum log level we should output
74 * Sets the threshold for log output; anything logged with a log level
75 * lower than this will be silently dropped. Returns the old log threshold
78 loglevels setlogthreshold(loglevels loglevel);
81 * logthing - output a log entry
82 * @loglevel: The level of the log.
83 * @format: A format string, followed by any parameters required.
85 * This function outputs a log entry. A leading time/date stamp and a
86 * trailing newline are automatically added. The loglevel is compared to
87 * the current log threshold and if equal or above the log entry is
88 * output. The format parameter is of the same nature as that used in
91 int logthing(loglevels loglevel, const char *format, ...);
93 #endif /* __LOG_H__ */