X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=include%2Fircd_log.h;h=48d63a87ed3572f5f9d737a066767629e9c22c7c;hb=refs%2Fheads%2Fupstream-ssl;hp=e16b08716b232de16495a52e03194341297cd832;hpb=13e5ea0dd2bc6ff69a492189165a80d6a922ab05;p=ircu2.10.12-pk.git diff --git a/include/ircd_log.h b/include/ircd_log.h index e16b087..48d63a8 100644 --- a/include/ircd_log.h +++ b/include/ircd_log.h @@ -14,9 +14,10 @@ * 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. - * - * - * $Id$ + */ +/** @file + * @brief IRC logging interface. + * @version $Id$ */ #ifndef INCLUDED_ircd_log_h #define INCLUDED_ircd_log_h @@ -25,32 +26,49 @@ #include /* va_list */ #define INCLUDED_stdarg_h #endif +#ifndef INCLUDED_stdlib_h +#include /* abort */ +#define INCLUDED_stdlib_h +#endif struct Client; /* WARNING WARNING WARNING -- Order is important; these enums are * used as indexes into arrays. */ - +/** Level of a log message. */ enum LogLevel { - L_CRIT, - L_ERROR, - L_WARNING, - L_NOTICE, - L_TRACE, - L_INFO, - L_DEBUG, - L_LAST_LEVEL + L_CRIT, /**< Critical failure. */ + L_ERROR, /**< Serious error. */ + L_WARNING, /**< Recoverable warning. */ + L_NOTICE, /**< Important status messages. */ + L_TRACE, /**< Client exit and kill logging. */ + L_INFO, /**< Logging of other operator commands. */ + L_DEBUG, /**< Debug message output. */ + L_LAST_LEVEL /**< Count of valid LogLevel values. */ }; +/** Log systems. */ enum LogSys { - LS_SYSTEM, LS_CONFIG, LS_OPERMODE, LS_GLINE, LS_JUPE, LS_WHO, LS_NETWORK, - LS_OPERKILL, LS_SERVKILL, LS_USER, LS_OPER, LS_RESOLVER, LS_SOCKET, - LS_DEBUG, LS_OLDLOG, - LS_LAST_SYSTEM + LS_SYSTEM, /**< Operational status changes. */ + LS_CONFIG, /**< Configuration errors and warnings. */ + LS_OPERMODE, /**< Uses of OPMODE, CLEARMODE< etc. */ + LS_GLINE, /**< Adding, (de-)activating or removing GLINEs. */ + LS_JUPE, /**< Adding, (de-)activating or removing JUPEs. */ + LS_WHO, /**< Use of extended WHO privileges. */ + LS_NETWORK, /**< New server connections. */ + LS_OPERKILL, /**< Kills by IRC operators. */ + LS_SERVKILL, /**< Kills by servers. */ + LS_USER, /**< User exits. */ + LS_OPER, /**< Users becoming operators. */ + LS_RESOLVER, /**< DNS resolver errors. */ + LS_SOCKET, /**< Unexpected socket operation errors. */ + LS_IAUTH, /**< IAuth status. */ + LS_DEBUG, /**< Debug messages. */ + LS_LAST_SYSTEM /**< Count of valid LogSys values. */ }; -extern void log_debug_init(char *file); +extern void log_debug_init(int usetty); extern void log_init(const char *process_name); extern void log_reopen(void); extern void log_close(void); @@ -63,12 +81,13 @@ extern void log_vwrite(enum LogSys subsys, enum LogLevel severity, extern void log_write_kill(const struct Client *victim, const struct Client *killer, const char *inpath, - const char *path); - -#define LOG_NOSYSLOG 0x01 -#define LOG_NOFILELOG 0x02 -#define LOG_NOSNOTICE 0x04 + const char *path, + const char *msg); +#define LOG_NOSYSLOG 0x01 /**< Do not send message to syslog. */ +#define LOG_NOFILELOG 0x02 /**< Do not send message to a log file. */ +#define LOG_NOSNOTICE 0x04 /**< Do not send message via server notice. */ +/** Bitmask of suppression flags for log_write() and log_vwrite(). */ #define LOG_NOMASK (LOG_NOSYSLOG | LOG_NOFILELOG | LOG_NOSNOTICE) extern char *log_canon(const char *subsys); @@ -88,6 +107,51 @@ extern char *log_get_level(const char *subsys); extern int log_set_default(const char *facility); extern char *log_get_default(void); -extern void log_feature_report(struct Client *to); +extern void log_feature_unmark(void); +extern int log_feature_mark(int flag); +extern void log_feature_report(struct Client *to, int flag); + +extern int log_inassert; #endif /* INCLUDED_ircd_log_h */ + +/* The rest of this file implements our own custom version of assert. + * This version will log the assertion failure using the LS_SYSTEM log + * stream, thus putting the assertion failure message into a useful + * place, rather than elsewhere, as is currently the case... + */ + +/* We've been included twice; clean up before creating assert() again */ +#ifdef _ircd_log_assert +# undef _ircd_log_assert +# undef assert +#endif + +/* gcc has a nice way of hinting that an expression is expected to + * produce a specific result, which can improve optimization. + * Unfortunately, all the world's not gcc (at least, not yet), and not + * all gcc's support it. I don't know exactly when it appeared, but + * it does appear to be in all versions from 3 and up. So, we'll + * create a dummy define if (we think) this version of gcc doesn't + * have it... + */ +#ifndef _log_builtin_expect +# define _log_builtin_expect +# if __GNUC__ < 3 +# define __builtin_expect(expr, expect) (expr) +# endif +#endif + +/* let's try not to clash with the system assert()... */ +#ifndef assert +# ifdef NDEBUG +# define assert(expr) ((void)0) +# else +# define assert(expr) \ + ((void)(__builtin_expect(!!(expr), 1) ? 0 : \ + (__builtin_expect(log_inassert, 0) ? (abort(), 0) : \ + ((log_inassert = 1), /* inhibit looping in assert() */ \ + log_write(LS_SYSTEM, L_CRIT, 0, "Assertion failure at %s:%d: " \ + "\"%s\"", __FILE__, __LINE__, #expr), abort(), 0)))) +# endif +#endif