]> jfr.im git - irc/quakenet/snircd.git/blame - doc/api/log.txt
Initial import of 2.10.12.01
[irc/quakenet/snircd.git] / doc / api / log.txt
CommitLineData
189935b1 1Old versions of ircu did not have very good means of dealing with
2logging. In u2.10.11, an entirely new logging subsystem was written,
3allowing a server administrator much more power in determining what
4actions are to be logged where. The new logging subsystem permits log
5messages to go to syslog, to a file, and to server operators via
6server notices, simultaneously (though having output to multiple log
7files is not presently supported).
8
9All log messages have two values that are passed in with them: the
10logging level, which must be one of the values in enum LogLevel, and a
11logging subsystem, which must be one of the values in enum LogSys;
12these values are used as indexes into arrays within ircd_log.c, so be
13careful should you change them.
14
15In addition to the LogLevel and LogSys, there is also a set of three
16flags that may be passed to the log_write() logging function; these
17flags may be used to suppress certain types of logging that may be
18undesirable. For instance, when a server links, a log may be written
19containing the server's IP address; to prevent this IP address from
20ever showing up in a server notice, that invocation of log_write() is
21passed the LOG_NOSNOTICE flag.
22
23<enum>
24enum LogLevel {
25 L_CRIT,
26 L_ERROR,
27 L_WARNING,
28 L_NOTICE,
29 L_TRACE,
30 L_INFO,
31 L_DEBUG,
32 L_LAST_LEVEL
33};
34
35This enum describes the severity levels of a log message. The
36severity decreases as you proceed downwards in the list, so L_DEBUG is
37less severe than L_INFO, and L_CRIT in the most severe of all. The
38special value L_LAST_LEVEL should never be used; it merely marks the
39end of the list.
40</enum>
41
42<enum>
43enum LogSys {
44 LS_SYSTEM, LS_CONFIG, LS_OPERMODE, LS_GLINE, LS_JUPE, LS_WHO, LS_NETWORK,
45 LS_OPERKILL, LS_SERVKILL, LS_USER, LS_OPER, LS_RESOLVER, LS_SOCKET,
46 LS_DEBUG, LS_OLDLOG,
47 LS_LAST_SYSTEM
48};
49
50These are the various logging subsystems recognized by the logging
51subsystem. Again, order is important, and again, LS_LAST_SYSTEM
52should never be used.
53</enum>
54
55<function>
56void log_debug_init(int usetty);
57
58This initializes the special-purpose debug logging code in the
59server. If the _usetty_ parameter is non-zero, then all debugging
60output will go to the terminal regardless of file settings for the
61LS_DEBUG subsystem. This function is not defined unless the server is
62compiled with -DDEBUGMODE.
63</function>
64
65<function>
66void log_init(const char *process_name);
67
68This initializes the entire logging subsystem, including special
69things such as storing the process name and opening syslog with the
70open_log() function. It may only be called once.
71</function>
72
73<function>
74void log_reopen(void);
75
76All log files are persistently open, in order to avoid the overhead of
77re-opening the log file each time. This function is used to close all
78the log files and to close and reopen syslog. (Log files are opened
79again only when there is something to write to them.)
80</function>
81
82<function>
83void log_close(void);
84
85This closes all log files and the syslog prior to the server
86terminating. Should logs need to be reopened after calling this
87function, call log_reopen() instead of log_init().
88</function>
89
90<function>
91void log_write(enum LogSys subsys, enum LogLevel severity,
92 unsigned int flags, const char *fmt, ...);
93
94This is the actual logging function. The _flags_ parameter is 0 or
95the bitwise OR of LOG_NOSYSLOG (suppresses syslogging), LOG_NOFILELOG
96(suppresses logging to a file) and LOG_NOSNOTICE (suppresses logging
97via server notices). The _fmt_ parameter is a format string
98acceptable to ircd_snprintf(), which is the function called to
99actually format the log message.
100</function>
101
102<function>
103void log_vwrite(enum LogSys subsys, enum LogLevel severity,
104 unsigned int flags, const char *fmt, va_list vl);
105
106This is similar to log_write() except that it takes a va_list
107parameter.
108</function>
109
110<function>
111char *log_cannon(const char *subsys);
112
113This returns the canonical name for logging subsystem. This probably
114should not be exposed here, but it is needed in ircd_features.c at
115present.
116</function>
117
118<function>
119int log_set_file(const char *subsys, const char *filename);
120
121This sets the file name for the specified logging subsystem to
122_filename_; returns 2 if the subsystem was undefined, 1 if the value
123of _filename_ was not understood, or 0 if there was no error.
124</function>
125
126<function>
127char *log_get_file(const char *subsys);
128
129This returns the current log file name for the given subsystem.
130</function>
131
132<function>
133int log_set_facility(const char *subsys, const char *facility);
134
135This sets the syslog facility for the specified logging subsystem to
136_facility_; returns 2 if the subsystem was undefined, 1 if the value
137of _facility_ was not understood, or 0 if there was no error. Two
138special facility names may be given; "NONE" specifies that no
139syslogging should be performed, and "DEFAULT" specifies that ircd's
140default syslog facility should be used.
141</function>
142
143<function>
144char *log_get_facility(const char *subsys);
145
146This returns the current syslog facility for the given subsystem. See
147the documentation for log_set_facility() for a description of the
148special facility names "NONE" and "DEFAULT."
149</function>
150
151<function>
152int log_set_snomask(const char *subsys, const char *snomask);
153
154This sets the server notice type for the specified logging subsystem
155to _snomask_; returns 2 if the subsystem was undefined, 1 if the value
156of _snomask_ was not understood, or 0 if there was no error. The
157special server notice type "NONE" indicates that no server notices
158should be generated. The other valid values for _snomask_ are:
159"OLDSNO," "SERVKILL," "OPERKILL," "HACK2," "HACK3," "UNAUTH,"
160"TCPCOMMON," "TOOMANY," "HACK4," "GLINE," "NETWORK," "IPMISMATCH,"
161"THROTTLE," "OLDREALOP," "CONNEXIT," and "DEBUG."
162</function>
163
164<function>
165char *log_get_snomask(const char *subsys);
166
167This returns the current server notice type for the given subsystem.
168See the documentation for log_set_snomask() for a description of the
169return values.
170</function>
171
172<function>
173int log_set_level(const char *subsys, const char *level);
174
175This function is used to set the minimum log level for a particular
176subsystem; returns 2 if the subsystem was undefined, 1 if the value of
177_level_ was not understood, or 0 if there was no error. Any log
178notices generated with lower severity than that set with this function
179will not be logged. Valid values are "CRIT," "ERROR," "WARNING,"
180"NOTICE," "TRACE," "INFO," and "DEBUG."
181</function>
182
183<function>
184char *log_get_level(const char *subsys);
185
186This returns the current minimum log level for the given subsystem.
187See the documentation for log_set_level() for a description of the
188return values.
189</function>
190
191<function>
192int log_set_default(const char *facility);
193
194This function sets the default syslog facility for all of ircd. Valid
195values for _facility_ are as described for log_set_facility() with the
196exclusion of the "NONE" and "DEFAULT" facilities; returns 1 if the
197facility name was unrecognized (or proscribed) or 0 if there was no
198error.
199</function>
200
201<function>
202char *log_get_default(void);
203
204This simply returns ircd's default syslog facility.
205</function>
206
207<function>
208void log_feature_unmark(void);
209
210This function is called by the ircd_features.c subsystem and should
211not be called by any other part of ircd. See the features API
212documentation for notes on what this function does.
213</function>
214
215<function>
216void log_feature_mark(int flag);
217
218This function is called by the ircd_features.c subsystem and should
219not be called by any other part of ircd. See the features API
220documentation for notes on what this function does.
221</function>
222
223<function>
224void log_feature_report(struct Client *to, int flag);
225
226This function is called by the ircd_features.c subsystem and should
227not be called by any other part of ircd. See the features API
228documentation for notes on what this function does.
229</function>
230
231<authors>
232Kev <klmitch@mit.edu>
233</authors>
234
235<changelog>
236[2001-06-13 Kev] Fix a minor typo.
237
238[2000-12-18 Kev] Wrote some documentation on how to use the logging
239subsystem.
240</changelog>