* IRC - Internet Relay Chat, src/ircd_log.c
* Copyright (C) 1999 Thomas Helvey (BleepSoft)
* Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
* IRC - Internet Relay Chat, src/ircd_log.c
* Copyright (C) 1999 Thomas Helvey (BleepSoft)
* Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#define LOG_DOSYSLOG 0x10
-#define LOG_DOFILELOG 0x20
-#define LOG_DOSNOTICE 0x40
-
+#define LOG_DOSYSLOG 0x10 /**< Try to use syslog. */
+#define LOG_DOFILELOG 0x20 /**< Try to log to a file. */
+#define LOG_DOSNOTICE 0x40 /**< Try to notify operators via notice. */
+/** Bitmask of valid delivery mechanisms. */
- enum LogLevel level;
- char *string;
- int syslog;
- unsigned int snomask; /* 0 means use default in LogDesc */
+ enum LogLevel level; /**< Log level being described. */
+ char *string; /**< Textual name of level. */
+ int syslog; /**< Syslog priority for log level. */
+ unsigned int snomask; /**< Server notice mask; 0 means use default in LogDesc. */
} levelData[] = {
#define L(level, syslog, mask) { L_ ## level, #level, (syslog), (mask) }
L(CRIT, LOG_CRIT, SNO_OLDSNO),
} levelData[] = {
#define L(level, syslog, mask) { L_ ## level, #level, (syslog), (mask) }
L(CRIT, LOG_CRIT, SNO_OLDSNO),
-#define LOG_NONE -1 /* don't syslog */
-#define LOG_DEFAULT 0 /* syslog to logInfo.facility */
-#define LOG_NOTFOUND -2 /* didn't find a facility corresponding to name */
+#define LOG_NONE -1 /**< don't syslog */
+#define LOG_DEFAULT 0 /**< syslog to logInfo.facility */
+#define LOG_NOTFOUND -2 /**< didn't find a facility corresponding to name */
} facilities[] = {
#define F(fac) { #fac, LOG_ ## fac }
F(NONE), F(DEFAULT), F(AUTH),
} facilities[] = {
#define F(fac) { #fac, LOG_ ## fac }
F(NONE), F(DEFAULT), F(AUTH),
-#define SNO_NONE 0x00000000 /* don't send server notices */
-#define SNO_NOTFOUND 0xffffffff /* didn't find a SNO_MASK value for name */
+#define SNO_NONE 0x00000000 /**< don't send server notices */
+#define SNO_NOTFOUND 0xffffffff /**< didn't find a SNO_MASK value for name */
} masks[] = {
#define M(mask) { #mask, SNO_ ## mask }
M(NONE), M(OLDSNO), M(SERVKILL), M(OPERKILL), M(HACK2),
M(HACK3), M(UNAUTH), M(TCPCOMMON), M(TOOMANY), M(HACK4),
M(GLINE), M(NETWORK), M(IPMISMATCH), M(THROTTLE), M(OLDREALOP),
} masks[] = {
#define M(mask) { #mask, SNO_ ## mask }
M(NONE), M(OLDSNO), M(SERVKILL), M(OPERKILL), M(HACK2),
M(HACK3), M(UNAUTH), M(TCPCOMMON), M(TOOMANY), M(HACK4),
M(GLINE), M(NETWORK), M(IPMISMATCH), M(THROTTLE), M(OLDREALOP),
-#define LOG_MARK_FILE 0x0001 /* file has been changed */
-#define LOG_MARK_FACILITY 0x0002 /* facility has been changed */
-#define LOG_MARK_SNOMASK 0x0004 /* snomask has been changed */
-#define LOG_MARK_LEVEL 0x0008 /* level has been changed */
+#define LOG_MARK_FILE 0x0001 /**< file has been changed */
+#define LOG_MARK_FACILITY 0x0002 /**< facility has been changed */
+#define LOG_MARK_SNOMASK 0x0004 /**< snomask has been changed */
+#define LOG_MARK_LEVEL 0x0008 /**< level has been changed */
- enum LogSys subsys; /* number for subsystem */
- char *name; /* subsystem name */
- struct LogFile *file; /* file descriptor for subsystem */
- unsigned int mark; /* subsystem has been changed */
- int def_fac; /* default facility */
- unsigned int def_sno; /* default snomask */
- int facility; /* -1 means don't use syslog */
- unsigned int snomask; /* 0 means no server message */
- enum LogLevel level; /* logging level */
+ enum LogSys subsys; /**< number for subsystem */
+ char *name; /**< subsystem name */
+ struct LogFile *file; /**< file descriptor for subsystem */
+ unsigned int mark; /**< subsystem has been changed */
+ int def_fac; /**< default facility */
+ unsigned int def_sno; /**< default snomask */
+ int facility; /**< -1 means don't use syslog */
+ unsigned int snomask; /**< 0 means no server message */
+ enum LogLevel level; /**< logging level */
} logDesc[] = {
#define S(sys, p, sn) { LS_##sys, #sys, 0, 0, (p), (sn), (p), (sn), L_DEFAULT }
S(SYSTEM, -1, 0),
} logDesc[] = {
#define S(sys, p, sn) { LS_##sys, #sys, 0, 0, (p), (sn), (p), (sn), L_DEFAULT }
S(SYSTEM, -1, 0),
S(OPER, -1, SNO_OLDREALOP),
S(RESOLVER, -1, 0),
S(SOCKET, -1, 0),
S(OPER, -1, SNO_OLDREALOP),
S(RESOLVER, -1, 0),
S(SOCKET, -1, 0),
#undef S
{ LS_LAST_SYSTEM, 0, 0, -1, 0, -1, 0 }
};
#undef S
{ LS_LAST_SYSTEM, 0, 0, -1, 0, -1, 0 }
};
- struct LogFile *next; /* next log file descriptor */
- struct LogFile **prev_p; /* what points to us */
- int fd; /* file's descriptor-- -1 if not open */
- int ref; /* how many things refer to us? */
- char *file; /* file name */
+ struct LogFile *next; /**< next log file descriptor */
+ struct LogFile **prev_p; /**< what points to us */
+ int fd; /**< file's descriptor-- -1 if not open */
+ int ref; /**< how many things refer to us? */
+ char *file; /**< file name */
- struct LogFile *filelist; /* list of log files */
- struct LogFile *freelist; /* list of free'd log files */
- int facility; /* default facility */
- const char *procname; /* process's name */
- struct LogFile *dbfile; /* debug file */
+ struct LogFile *filelist; /**< list of log files */
+ struct LogFile *freelist; /**< list of free'd log files */
+ int facility; /**< default facility */
+ const char *procname; /**< process's name */
+ struct LogFile *dbfile; /**< debug file */
} logInfo = { 0, 0, LOG_USER, "ircd", 0 };
} logInfo = { 0, 0, LOG_USER, "ircd", 0 };
-/* helper routine to open a log file if needed */
+/** Helper routine to open a log file if needed.
+ * If the log file is already open, do nothing.
+ * @param[in,out] lf Log file to open.
+ */
-/* set the debug log file */
+/** Set the debug log file name.
+ * @param[in] file File name, or NULL to select the default.
+ * @return Zero if the file was reopened; non-zero if not debugging to file.
+ */
-/* These write entries to a log file */
+/** Write a logging entry.
+ * @param[in] subsys Target subsystem.
+ * @param[in] severity Severity of message.
+ * @param[in] flags Combination of zero or more of LOG_NOSYSLOG, LOG_NOFILELOG, LOG_NOSNOTICE to suppress certain output.
+ * @param[in] fmt Format string for message.
+ */
void
log_write(enum LogSys subsys, enum LogLevel severity, unsigned int flags,
const char *fmt, ...)
void
log_write(enum LogSys subsys, enum LogLevel severity, unsigned int flags,
const char *fmt, ...)
+/** Write a logging entry using a va_list.
+ * @param[in] subsys Target subsystem.
+ * @param[in] severity Severity of message.
+ * @param[in] flags Combination of zero or more of LOG_NOSYSLOG, LOG_NOFILELOG, LOG_NOSNOTICE to suppress certain output.
+ * @param[in] fmt Format string for message.
+ * @param[in] vl Variable-length argument list for message.
+ */
void
log_vwrite(enum LogSys subsys, enum LogLevel severity, unsigned int flags,
const char *fmt, va_list vl)
void
log_vwrite(enum LogSys subsys, enum LogLevel severity, unsigned int flags,
const char *fmt, va_list vl)
-/* log kills for fun and profit */
+/** Log an appropriate message for kills.
+ * @param[in] victim %Client being killed.
+ * @param[in] killer %User or server doing the killing.
+ * @param[in] inpath Peer that sent us the KILL message.
+ * @param[in] path Kill path that sent to us by \a inpath.
+ * @param[in] msg Kill reason.
+ */
{
if (MyUser(victim))
log_write(IsServer(killer) ? LS_SERVKILL : LS_OPERKILL, L_TRACE, 0,
{
if (MyUser(victim))
log_write(IsServer(killer) ? LS_SERVKILL : LS_OPERKILL, L_TRACE, 0,
- "A local client %#C KILLED by %#C Path: %s!%s",
- victim, killer, inpath, path);
+ "A local client %#C KILLED by %#C Path: %s!%s %s",
+ victim, killer, inpath, path, msg);
else
log_write(IsServer(killer) ? LS_SERVKILL : LS_OPERKILL, L_TRACE, 0,
else
log_write(IsServer(killer) ? LS_SERVKILL : LS_OPERKILL, L_TRACE, 0,
- "KILL from %C For %C Path: %s!%s", killer, victim, inpath, path);
+ "KILL from %C For %C Path: %s!%s %s", killer, victim, inpath,
+ path, msg);
-/* return a struct LogFile for a specific filename--reference counted */
+/** Find a reference-counted LogFile by file name.
+ * @param[in] file Name of file.
+ * @return A log file descriptor with LogFile::ref at least 1.
+ */
-/* destroy a log file descriptor, under the control of the reference count */
+/** Dereference a log file.
+ * If the reference count is exactly one on entry to this function,
+ * the file is closed and its structure is freed.
+ * @param[in] lf Log file to dereference.
+ */
-/* finds a subsystem given its name */
+/** Look up a log subsystem by name.
+ * @param[in] subsys Subsystem name.
+ * @return Pointer to the subsystem's LogDesc, or NULL if none exists.
+ */
-/* find a level given its name */
+/** Look up a log level by name.
+ * @param[in] level Log level name.
+ * @return LogLevel enumeration, or L_LAST_LEVEL if none exists.
+ */
-/* find a facility given its name */
+/** Look up a syslog facility by name.
+ * @param[in] facility Facility name.
+ * @return Syslog facility value, or LOG_NOTFOUND if none exists.
+ */
-/* return a name for a facility */
+/** Look up the name for a syslog facility.
+ * @param[in] fac Facility value.
+ * @return Canonical name for facility, or NULL if none exists.
+ */
-/* find a snomask value given its name */
+/** Look up a server notice mask by name.
+ * @param[in] maskname Name of server notice mask.
+ * @return Bitmask for server notices, or 0 if none exists.
+ */
-/* return a name for a snomask value */
+/** Look up the canonical name for a server notice mask.
+ * @param[in] sno Server notice mask.
+ * @return Canonical name for the mask, or NULL if none exists.
+ */
-/* set the log file for a subsystem */
+/** Set a log file for a particular subsystem.
+ * @param[in] subsys Subsystem name.
+ * @param[in] filename Log file to write to.
+ * @return Zero on success; non-zero on error.
+ */
if (filename)
desc->mark |= LOG_MARK_FILE; /* mark that file has been changed */
else
desc->mark &= ~LOG_MARK_FILE; /* file has been reset to defaults */
if (filename)
desc->mark |= LOG_MARK_FILE; /* mark that file has been changed */
else
desc->mark &= ~LOG_MARK_FILE; /* file has been reset to defaults */
/* debug log is special, since it has to be opened on fd 2 */
if (desc->subsys == LS_DEBUG)
return log_debug_file(filename);
/* debug log is special, since it has to be opened on fd 2 */
if (desc->subsys == LS_DEBUG)
return log_debug_file(filename);
-/* get the log file for a subsystem */
+/** Find the log file name for a subsystem.
+ * @param[in] subsys Subsystem name.
+ * @return Log file for the subsystem, or NULL if not being logged to a file.
+ */
-/* set the facility for a subsystem */
+/** Set the syslog facility for a particular subsystem.
+ * @param[in] subsys Subsystem name.
+ * @param[in] facility Facility name to log to.
+ * @return Zero on success; non-zero on error.
+ */
-/* get the facility for a subsystem */
+/** Find the facility name for a subsystem.
+ * @param[in] subsys Subsystem name.
+ * @return Facility name being used, or NULL if not being logged to syslog.
+ */
-/* set the snomask value for a subsystem */
+/** Set the server notice mask for a subsystem.
+ * @param[in] subsys Subsystem name.
+ * @param[in] snomask Server notice mask name.
+ * @return Zero on success; non-zero on error.
+ */
-/* get the snomask value for a subsystem */
+/** Find the server notice mask name for a subsystem.
+ * @param[in] subsys Subsystem name.
+ * @return Name of server notice mask being used, or NULL if none.
+ */
-/* set the level for a subsystem */
+/** Set the verbosity level for a subsystem.
+ * @param[in] subsys Subsystem name.
+ * @param[in] level Minimum log level.
+ * @return Zero on success; non-zero on error.
+ */
-/* get the level for a subsystem */
+/** Find the verbosity level for a subsystem.
+ * @param[in] subsys Subsystem name.
+ * @return Minimum verbosity level being used, or NULL on error.
+ */
-/* set the overall default syslog facility */
+/** Set the default syslog facility.
+ * @param[in] facility Syslog facility name.
+ * @return Zero on success, non-zero on error.
+ */
-/* Report feature settings */
+/** Feature list callback to report log settings.
+ * @param[in] to Client requesting list.
+ * @param[in] flag If non-zero, report default syslog facility.
+ */
if (logDesc[i].mark & LOG_MARK_FILE) /* report file */
send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F LOG %s FILE %s",
if (logDesc[i].mark & LOG_MARK_FILE) /* report file */
send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F LOG %s FILE %s",
if (logDesc[i].mark & LOG_MARK_FACILITY) /* report facility */
send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F LOG %s FACILITY %s",
if (logDesc[i].mark & LOG_MARK_FACILITY) /* report facility */
send_reply(to, SND_EXPLICIT | RPL_STATSFLINE, "F LOG %s FACILITY %s",