<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.darenet.org/skins/common/feed.css?12"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>ircu api - log - Revision history</title>
		<link>http://wiki.darenet.org/index.php?title=ircu_api_-_log&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.15.1</generator>
		<lastBuildDate>Wed, 20 May 2026 06:12:28 GMT</lastBuildDate>
		<item>
			<title>Secretagent:&amp;#32;New page: &lt;pre&gt;Old versions of ircu did not have very good means of dealing with logging.  In u2.10.11, an entirely new logging subsystem was written, allowing a server administrator much more power...</title>
			<link>http://wiki.darenet.org/index.php?title=ircu_api_-_log&amp;diff=2274&amp;oldid=prev</link>
			<description>&lt;p&gt;New page: &amp;lt;pre&amp;gt;Old versions of ircu did not have very good means of dealing with logging.  In u2.10.11, an entirely new logging subsystem was written, allowing a server administrator much more power...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;Old versions of ircu did not have very good means of dealing with&lt;br /&gt;
logging.  In u2.10.11, an entirely new logging subsystem was written,&lt;br /&gt;
allowing a server administrator much more power in determining what&lt;br /&gt;
actions are to be logged where.  The new logging subsystem permits log&lt;br /&gt;
messages to go to syslog, to a file, and to server operators via&lt;br /&gt;
server notices, simultaneously (though having output to multiple log&lt;br /&gt;
files is not presently supported).&lt;br /&gt;
&lt;br /&gt;
All log messages have two values that are passed in with them: the&lt;br /&gt;
logging level, which must be one of the values in enum LogLevel, and a&lt;br /&gt;
logging subsystem, which must be one of the values in enum LogSys;&lt;br /&gt;
these values are used as indexes into arrays within ircd_log.c, so be&lt;br /&gt;
careful should you change them.&lt;br /&gt;
&lt;br /&gt;
In addition to the LogLevel and LogSys, there is also a set of three&lt;br /&gt;
flags that may be passed to the log_write() logging function; these&lt;br /&gt;
flags may be used to suppress certain types of logging that may be&lt;br /&gt;
undesirable.  For instance, when a server links, a log may be written&lt;br /&gt;
containing the server's IP address; to prevent this IP address from&lt;br /&gt;
ever showing up in a server notice, that invocation of log_write() is&lt;br /&gt;
passed the LOG_NOSNOTICE flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;enum&amp;gt;&lt;br /&gt;
enum LogLevel {&lt;br /&gt;
  L_CRIT,&lt;br /&gt;
  L_ERROR,&lt;br /&gt;
  L_WARNING,&lt;br /&gt;
  L_NOTICE,&lt;br /&gt;
  L_TRACE,&lt;br /&gt;
  L_INFO,&lt;br /&gt;
  L_DEBUG,&lt;br /&gt;
  L_LAST_LEVEL&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
This enum describes the severity levels of a log message.  The&lt;br /&gt;
severity decreases as you proceed downwards in the list, so L_DEBUG is&lt;br /&gt;
less severe than L_INFO, and L_CRIT in the most severe of all.  The&lt;br /&gt;
special value L_LAST_LEVEL should never be used; it merely marks the&lt;br /&gt;
end of the list.&lt;br /&gt;
&amp;lt;/enum&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;enum&amp;gt;&lt;br /&gt;
enum LogSys {&lt;br /&gt;
  LS_SYSTEM, LS_CONFIG, LS_OPERMODE, LS_GLINE, LS_JUPE, LS_WHO, LS_NETWORK,&lt;br /&gt;
  LS_OPERKILL, LS_SERVKILL, LS_USER, LS_OPER, LS_RESOLVER, LS_SOCKET,&lt;br /&gt;
  LS_DEBUG, LS_OLDLOG,&lt;br /&gt;
  LS_LAST_SYSTEM&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
These are the various logging subsystems recognized by the logging&lt;br /&gt;
subsystem.  Again, order is important, and again, LS_LAST_SYSTEM&lt;br /&gt;
should never be used.&lt;br /&gt;
&amp;lt;/enum&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
void log_debug_init(int usetty);&lt;br /&gt;
&lt;br /&gt;
This initializes the special-purpose debug logging code in the&lt;br /&gt;
server.  If the _usetty_ parameter is non-zero, then all debugging&lt;br /&gt;
output will go to the terminal regardless of file settings for the&lt;br /&gt;
LS_DEBUG subsystem.  This function is not defined unless the server is&lt;br /&gt;
compiled with -DDEBUGMODE.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
void log_init(const char *process_name);&lt;br /&gt;
&lt;br /&gt;
This initializes the entire logging subsystem, including special&lt;br /&gt;
things such as storing the process name and opening syslog with the&lt;br /&gt;
open_log() function.  It may only be called once.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
void log_reopen(void);&lt;br /&gt;
&lt;br /&gt;
All log files are persistently open, in order to avoid the overhead of&lt;br /&gt;
re-opening the log file each time.  This function is used to close all&lt;br /&gt;
the log files and to close and reopen syslog.  (Log files are opened&lt;br /&gt;
again only when there is something to write to them.)&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
void log_close(void);&lt;br /&gt;
&lt;br /&gt;
This closes all log files and the syslog prior to the server&lt;br /&gt;
terminating.  Should logs need to be reopened after calling this&lt;br /&gt;
function, call log_reopen() instead of log_init().&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
void log_write(enum LogSys subsys, enum LogLevel severity,&lt;br /&gt;
	       unsigned int flags, const char *fmt, ...);&lt;br /&gt;
&lt;br /&gt;
This is the actual logging function.  The _flags_ parameter is 0 or&lt;br /&gt;
the bitwise OR of LOG_NOSYSLOG (suppresses syslogging), LOG_NOFILELOG&lt;br /&gt;
(suppresses logging to a file) and LOG_NOSNOTICE (suppresses logging&lt;br /&gt;
via server notices).  The _fmt_ parameter is a format string&lt;br /&gt;
acceptable to ircd_snprintf(), which is the function called to&lt;br /&gt;
actually format the log message.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
void log_vwrite(enum LogSys subsys, enum LogLevel severity,&lt;br /&gt;
		unsigned int flags, const char *fmt, va_list vl);&lt;br /&gt;
&lt;br /&gt;
This is similar to log_write() except that it takes a va_list&lt;br /&gt;
parameter.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
char *log_cannon(const char *subsys);&lt;br /&gt;
&lt;br /&gt;
This returns the canonical name for logging subsystem.  This probably&lt;br /&gt;
should not be exposed here, but it is needed in ircd_features.c at&lt;br /&gt;
present.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
int log_set_file(const char *subsys, const char *filename);&lt;br /&gt;
&lt;br /&gt;
This sets the file name for the specified logging subsystem to&lt;br /&gt;
_filename_; returns 2 if the subsystem was undefined, 1 if the value&lt;br /&gt;
of _filename_ was not understood, or 0 if there was no error.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
char *log_get_file(const char *subsys);&lt;br /&gt;
&lt;br /&gt;
This returns the current log file name for the given subsystem.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
int log_set_facility(const char *subsys, const char *facility);&lt;br /&gt;
&lt;br /&gt;
This sets the syslog facility for the specified logging subsystem to&lt;br /&gt;
_facility_; returns 2 if the subsystem was undefined, 1 if the value&lt;br /&gt;
of _facility_ was not understood, or 0 if there was no error.  Two&lt;br /&gt;
special facility names may be given; &amp;quot;NONE&amp;quot; specifies that no&lt;br /&gt;
syslogging should be performed, and &amp;quot;DEFAULT&amp;quot; specifies that ircd's&lt;br /&gt;
default syslog facility should be used.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
char *log_get_facility(const char *subsys);&lt;br /&gt;
&lt;br /&gt;
This returns the current syslog facility for the given subsystem.  See&lt;br /&gt;
the documentation for log_set_facility() for a description of the&lt;br /&gt;
special facility names &amp;quot;NONE&amp;quot; and &amp;quot;DEFAULT.&amp;quot;&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
int log_set_snomask(const char *subsys, const char *snomask);&lt;br /&gt;
&lt;br /&gt;
This sets the server notice type for the specified logging subsystem&lt;br /&gt;
to _snomask_; returns 2 if the subsystem was undefined, 1 if the value&lt;br /&gt;
of _snomask_ was not understood, or 0 if there was no error.  The&lt;br /&gt;
special server notice type &amp;quot;NONE&amp;quot; indicates that no server notices&lt;br /&gt;
should be generated.  The other valid values for _snomask_ are:&lt;br /&gt;
&amp;quot;OLDSNO,&amp;quot; &amp;quot;SERVKILL,&amp;quot; &amp;quot;OPERKILL,&amp;quot; &amp;quot;HACK2,&amp;quot; &amp;quot;HACK3,&amp;quot; &amp;quot;UNAUTH,&amp;quot;&lt;br /&gt;
&amp;quot;TCPCOMMON,&amp;quot; &amp;quot;TOOMANY,&amp;quot; &amp;quot;HACK4,&amp;quot; &amp;quot;GLINE,&amp;quot; &amp;quot;NETWORK,&amp;quot; &amp;quot;IPMISMATCH,&amp;quot;&lt;br /&gt;
&amp;quot;THROTTLE,&amp;quot; &amp;quot;OLDREALOP,&amp;quot; &amp;quot;CONNEXIT,&amp;quot; and &amp;quot;DEBUG.&amp;quot;&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
char *log_get_snomask(const char *subsys);&lt;br /&gt;
&lt;br /&gt;
This returns the current server notice type for the given subsystem.&lt;br /&gt;
See the documentation for log_set_snomask() for a description of the&lt;br /&gt;
return values.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
int log_set_level(const char *subsys, const char *level);&lt;br /&gt;
&lt;br /&gt;
This function is used to set the minimum log level for a particular&lt;br /&gt;
subsystem; returns 2 if the subsystem was undefined, 1 if the value of&lt;br /&gt;
_level_ was not understood, or 0 if there was no error.  Any log&lt;br /&gt;
notices generated with lower severity than that set with this function&lt;br /&gt;
will not be logged.  Valid values are &amp;quot;CRIT,&amp;quot; &amp;quot;ERROR,&amp;quot; &amp;quot;WARNING,&amp;quot;&lt;br /&gt;
&amp;quot;NOTICE,&amp;quot; &amp;quot;TRACE,&amp;quot; &amp;quot;INFO,&amp;quot; and &amp;quot;DEBUG.&amp;quot;&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
char *log_get_level(const char *subsys);&lt;br /&gt;
&lt;br /&gt;
This returns the current minimum log level for the given subsystem.&lt;br /&gt;
See the documentation for log_set_level() for a description of the&lt;br /&gt;
return values.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
int log_set_default(const char *facility);&lt;br /&gt;
&lt;br /&gt;
This function sets the default syslog facility for all of ircd.  Valid&lt;br /&gt;
values for _facility_ are as described for log_set_facility() with the&lt;br /&gt;
exclusion of the &amp;quot;NONE&amp;quot; and &amp;quot;DEFAULT&amp;quot; facilities; returns 1 if the&lt;br /&gt;
facility name was unrecognized (or proscribed) or 0 if there was no&lt;br /&gt;
error.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
char *log_get_default(void);&lt;br /&gt;
&lt;br /&gt;
This simply returns ircd's default syslog facility.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
void log_feature_unmark(void);&lt;br /&gt;
&lt;br /&gt;
This function is called by the ircd_features.c subsystem and should&lt;br /&gt;
not be called by any other part of ircd.  See the features API&lt;br /&gt;
documentation for notes on what this function does.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
void log_feature_mark(int flag);&lt;br /&gt;
&lt;br /&gt;
This function is called by the ircd_features.c subsystem and should&lt;br /&gt;
not be called by any other part of ircd.  See the features API&lt;br /&gt;
documentation for notes on what this function does.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;function&amp;gt;&lt;br /&gt;
void log_feature_report(struct Client *to, int flag);&lt;br /&gt;
&lt;br /&gt;
This function is called by the ircd_features.c subsystem and should&lt;br /&gt;
not be called by any other part of ircd.  See the features API&lt;br /&gt;
documentation for notes on what this function does.&lt;br /&gt;
&amp;lt;/function&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;authors&amp;gt;&lt;br /&gt;
Kev &amp;lt;klmitch@mit.edu&amp;gt;&lt;br /&gt;
&amp;lt;/authors&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;changelog&amp;gt;&lt;br /&gt;
[2001-06-13 Kev] Fix a minor typo.&lt;br /&gt;
&lt;br /&gt;
[2000-12-18 Kev] Wrote some documentation on how to use the logging&lt;br /&gt;
subsystem.&lt;br /&gt;
&amp;lt;/changelog&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:IRCu API|Log]]&lt;/div&gt;</description>
			<pubDate>Fri, 25 Apr 2008 04:04:28 GMT</pubDate>			<dc:creator>Secretagent</dc:creator>			<comments>http://wiki.darenet.org/Talk:ircu_api_-_log</comments>		</item>
	</channel>
</rss>