1 Old versions of ircu did not have very good means of dealing with
2 logging. In u2.10.11, an entirely new logging subsystem was written,
3 allowing a server administrator much more power in determining what
4 actions are to be logged where. The new logging subsystem permits log
5 messages to go to syslog, to a file, and to server operators via
6 server notices, simultaneously (though having output to multiple log
7 files is not presently supported).
9 All log messages have two values that are passed in with them: the
10 logging level, which must be one of the values in enum LogLevel, and a
11 logging subsystem, which must be one of the values in enum LogSys;
12 these values are used as indexes into arrays within ircd_log.c, so be
13 careful should you change them.
15 In addition to the LogLevel and LogSys, there is also a set of three
16 flags that may be passed to the log_write() logging function; these
17 flags may be used to suppress certain types of logging that may be
18 undesirable. For instance, when a server links, a log may be written
19 containing the server's IP address; to prevent this IP address from
20 ever showing up in a server notice, that invocation of log_write() is
21 passed the LOG_NOSNOTICE flag.
35 This enum describes the severity levels of a log message. The
36 severity decreases as you proceed downwards in the list, so L_DEBUG is
37 less severe than L_INFO, and L_CRIT in the most severe of all. The
38 special value L_LAST_LEVEL should never be used; it merely marks the
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,
50 These are the various logging subsystems recognized by the logging
51 subsystem. Again, order is important, and again, LS_LAST_SYSTEM
56 void log_debug_init(int usetty);
58 This initializes the special-purpose debug logging code in the
59 server. If the _usetty_ parameter is non-zero, then all debugging
60 output will go to the terminal regardless of file settings for the
61 LS_DEBUG subsystem. This function is not defined unless the server is
62 compiled with -DDEBUGMODE.
66 void log_init(const char *process_name);
68 This initializes the entire logging subsystem, including special
69 things such as storing the process name and opening syslog with the
70 open_log() function. It may only be called once.
74 void log_reopen(void);
76 All log files are persistently open, in order to avoid the overhead of
77 re-opening the log file each time. This function is used to close all
78 the log files and to close and reopen syslog. (Log files are opened
79 again only when there is something to write to them.)
85 This closes all log files and the syslog prior to the server
86 terminating. Should logs need to be reopened after calling this
87 function, call log_reopen() instead of log_init().
91 void log_write(enum LogSys subsys, enum LogLevel severity,
92 unsigned int flags, const char *fmt, ...);
94 This is the actual logging function. The _flags_ parameter is 0 or
95 the bitwise OR of LOG_NOSYSLOG (suppresses syslogging), LOG_NOFILELOG
96 (suppresses logging to a file) and LOG_NOSNOTICE (suppresses logging
97 via server notices). The _fmt_ parameter is a format string
98 acceptable to ircd_snprintf(), which is the function called to
99 actually format the log message.
103 void log_vwrite(enum LogSys subsys, enum LogLevel severity,
104 unsigned int flags, const char *fmt, va_list vl);
106 This is similar to log_write() except that it takes a va_list
111 char *log_cannon(const char *subsys);
113 This returns the canonical name for logging subsystem. This probably
114 should not be exposed here, but it is needed in ircd_features.c at
119 int log_set_file(const char *subsys, const char *filename);
121 This sets the file name for the specified logging subsystem to
122 _filename_; returns 2 if the subsystem was undefined, 1 if the value
123 of _filename_ was not understood, or 0 if there was no error.
127 char *log_get_file(const char *subsys);
129 This returns the current log file name for the given subsystem.
133 int log_set_facility(const char *subsys, const char *facility);
135 This sets the syslog facility for the specified logging subsystem to
136 _facility_; returns 2 if the subsystem was undefined, 1 if the value
137 of _facility_ was not understood, or 0 if there was no error. Two
138 special facility names may be given; "NONE" specifies that no
139 syslogging should be performed, and "DEFAULT" specifies that ircd's
140 default syslog facility should be used.
144 char *log_get_facility(const char *subsys);
146 This returns the current syslog facility for the given subsystem. See
147 the documentation for log_set_facility() for a description of the
148 special facility names "NONE" and "DEFAULT."
152 int log_set_snomask(const char *subsys, const char *snomask);
154 This sets the server notice type for the specified logging subsystem
155 to _snomask_; returns 2 if the subsystem was undefined, 1 if the value
156 of _snomask_ was not understood, or 0 if there was no error. The
157 special server notice type "NONE" indicates that no server notices
158 should 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."
165 char *log_get_snomask(const char *subsys);
167 This returns the current server notice type for the given subsystem.
168 See the documentation for log_set_snomask() for a description of the
173 int log_set_level(const char *subsys, const char *level);
175 This function is used to set the minimum log level for a particular
176 subsystem; 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
178 notices generated with lower severity than that set with this function
179 will not be logged. Valid values are "CRIT," "ERROR," "WARNING,"
180 "NOTICE," "TRACE," "INFO," and "DEBUG."
184 char *log_get_level(const char *subsys);
186 This returns the current minimum log level for the given subsystem.
187 See the documentation for log_set_level() for a description of the
192 int log_set_default(const char *facility);
194 This function sets the default syslog facility for all of ircd. Valid
195 values for _facility_ are as described for log_set_facility() with the
196 exclusion of the "NONE" and "DEFAULT" facilities; returns 1 if the
197 facility name was unrecognized (or proscribed) or 0 if there was no
202 char *log_get_default(void);
204 This simply returns ircd's default syslog facility.
208 void log_feature_unmark(void);
210 This function is called by the ircd_features.c subsystem and should
211 not be called by any other part of ircd. See the features API
212 documentation for notes on what this function does.
216 void log_feature_mark(int flag);
218 This function is called by the ircd_features.c subsystem and should
219 not be called by any other part of ircd. See the features API
220 documentation for notes on what this function does.
224 void log_feature_report(struct Client *to, int flag);
226 This function is called by the ircd_features.c subsystem and should
227 not be called by any other part of ircd. See the features API
228 documentation for notes on what this function does.
232 Kev <klmitch@mit.edu>
236 [2001-06-13 Kev] Fix a minor typo.
238 [2000-12-18 Kev] Wrote some documentation on how to use the logging