2 * gw-log.h: Logging facilities.
4 * Europagate, 1994-1995.
7 * Revision 1.6 1995/03/30 07:32:42 adam
8 * New log-level: GW_LOG_NOTICE. New 2709 function: iso2709_mk.
10 * Revision 1.5 1995/03/28 07:52:35 adam
11 * Bug fix: Bad log masks.
13 * Revision 1.4 1995/03/27 12:50:40 adam
14 * New level: GW_LOG_ERRNO.
16 * Revision 1.3 1995/02/23 08:32:11 adam
19 * Revision 1.1.1.1 1995/02/09 17:27:12 adam
20 * Initial version of email gateway under CVS control.
22 * Initial: Dec 7, 94 (Adam Dickmeiss)
27 /* The log level is an unsigned integer value with at least 16 bits */
29 /* The log levels are defined below */
30 #define GW_LOG_FATAL 0x01
31 #define GW_LOG_WARN 0x02
32 #define GW_LOG_ACCT 0x04
33 #define GW_LOG_STAT 0x08
34 #define GW_LOG_ERRNO 0x10
35 #define GW_LOG_NOTICE 0x20
37 /* All debug levels */
38 #define GW_LOG_DEBUG 0xffc0
39 /* Individual debug levels, x sould be in range 0-9 */
40 #define GW_LOG_DEBUGN(x) (0x40<<(x))
42 /* All levels on / All levels except debugging */
43 #define GW_LOG_ALL 0xffef
44 #define GW_LOG_DEFAULT 0x2f
46 void gw_log_init (const char *app_name);
48 Initialises the log-system. Application name is given by 'app_name' -
49 could be specified as argv[0]. The application name should not
52 All log messages are directed to stderr on return from this function.
53 Override this behaviour by using the gw_log_file function.
55 The log level is set to GW_LOG_DEFAULT. Override this with the
56 gw_log_level function.
58 The session id is set to 0. Use gw_log_session to change this.
61 void gw_log_level (unsigned level);
63 Sets the log to 'level' by using the GW_LOG_xxxx masks as described
67 void gw_log_session (int session);
69 Sets the session id to 'session'.
72 int gw_log_file (unsigned level, const char *fname);
74 Specifies that output given by 'level' should be appended to file 'fname'.
75 Thus, all log messages can be written to one file or several files.
76 If 'level' is GW_LOG_ALL all output is appended to the same file.
77 If 'fname' is NULL it means that the output is written to stderr.
78 If 'fname' is "" it means the output is written to stdout.
80 This function returns 0 on success; -1 on failure.
83 int gw_log (unsigned level, const char *event_type, const char *format, ...);
85 Append log message to one or more files. The value of parameter
86 'level' and the value given by the last gw_log_level call are bitwise
87 AND'ed. This value represents the log level for this message.
88 If this value is non-zero the 'event_type' and 'format' are used to
89 create the log entries which are appended to the log files specified by
90 the gw_log_file call(s).
92 The 'event_type' should not contain blanks.
93 This function returns 0 on success; -1 on failure.
96 char *gw_strdup (const char *s);
98 Works as strdup(3s), which is not defined by ANSI.
103 <appname> <session> <date> <level> <type> <parameter>
105 Assuming that a 'token' is separated by one or more blanks we have:
109 <date> one token yymmddhhmmss
113 <parameter> zero or more tokens.