Remove CVS Id tags.
[onak.git] / log.h
1 /*
2  * log.h - Simple logging framework.
3  *
4  * Jonathan McDowell <noodles@earth.li>
5  *
6  * Copyright 2003 Project Purple
7  */
8
9 #ifndef __LOG_H__
10 #define __LOG_H__
11
12 /*
13  *      loglevels - levels of severity for a log entry
14  *
15  *      These provide various different levels of severity for a log entry. In
16  *      acesending order they are:
17  *
18  *      LOGTHING_TRACE
19  *      LOGTHING_DEBUG
20  *      LOGTHING_INFO
21  *      LOGTHING_NOTICE
22  *      LOGTHING_ERROR
23  *      LOGTHING_SERIOUS
24  *      LOGTHING_CRITICAL
25  *
26  *      By default the log threshold is set to LOGTHING_NOTICE, meaning
27  *      anything with a lower priority won't be output.
28  */
29 typedef enum {
30         LOGTHING_TRACE = 0,
31         LOGTHING_DEBUG = 1,
32         LOGTHING_INFO = 2,
33         LOGTHING_NOTICE = 3,
34         LOGTHING_ERROR = 4,
35         LOGTHING_SERIOUS = 5,
36         LOGTHING_CRITICAL = 6
37 } loglevels;
38
39 /*
40  *      initlogthing - initialize the logging module
41  *      @appname: The application name to use in the log.
42  *      @filename: The filename to log to. NULL means stderr.
43  *
44  *      This function sets up the logging module ready to log. The appname is
45  *      written as part of every log entry and the filename is the file we
46  *      should log to. If the appname is NULL then none is written. If the
47  *      filename is NULL all output is sent to stderr.
48  */
49 int initlogthing(const char *appname, const char *filename);
50
51 /*
52  *      cleanuplogthing - clean up the logging module
53  *
54  *      This function cleans up the logging module after use.
55  */
56 void cleanuplogthing(void);
57
58 /*
59  *      setlogthreshold - set the threshold for log output
60  *      @loglevel: The minimum log level we should output
61  *
62  *      Sets the threshold for log output; anything logged with a log level
63  *      lower than this will be silently dropped. Returns the old log threshold
64  *      value.
65  */
66 loglevels setlogthreshold(loglevels loglevel);
67
68 /*
69  *      logthing - output a log entry
70  *      @loglevel: The level of the log.
71  *      @format: A format string, followed by any parameters required.
72  *
73  *      This function outputs a log entry. A leading time/date stamp and a
74  *      trailing newline are automatically added. The loglevel is compared to
75  *      the current log threshold and if equal or above the log entry is
76  *      output. The format parameter is of the same nature as that used in
77  *      printf.
78  */
79 int logthing(loglevels loglevel, const char *format, ...);
80
81 #endif /* __LOG_H__ */