/** * logger.h: Logstreams * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in doc/pod/gplicense.pod. * * $Id: logger.h,v 1.2 2007/09/16 18:54:42 pippijn Exp $ */ #ifndef LOGGER_H #define LOGGER_H #include /* logger.c */ struct logfile_t : object, zero_initialised { unsigned index; void *log_file; /* opaque: can either be mychan_t or FILE --nenolod */ char *log_path; unsigned int log_mask; public: // methods static logfile_t *create (char const * const log_path_, unsigned int log_mask); virtual void write (char const * const buf); void enter (); // XXX: naming? void leave (); private: virtual void _destroy (); }; E char *log_path; /* contains path to default log. */ E int log_force; enum loglevel { /* general */ LG_NONE = 1 << 0, /* don't log */ LG_INFO = 1 << 1, /* log general info */ LG_ERROR = 1 << 2, /* log real important stuff */ LG_IOERROR = 1 << 3, /* log I/O errors. */ LG_DEBUG = 1 << 4, /* log debugging stuff */ /* commands */ LG_CMD_ADMIN = 1 << 5, /* oper-only commands */ LG_CMD_REGISTER = 1 << 6, /* register/drop */ LG_CMD_SET = 1 << 7, /* change properties of static data */ LG_CMD_DO = 1 << 8, /* change properties of dynamic data */ LG_CMD_LOGIN = 1 << 9, /* login/logout */ LG_CMD_GET = 1 << 10, /* query information */ /* other */ LG_NETWORK = 1 << 11, /* netsplit/netjoin */ LG_WALLOPS = 1 << 12, /* NOTYET wallops from opers/other servers */ LG_RAWDATA = 1 << 13, /* all data sent/received */ LG_REGISTER = 1 << 14, /* all registration related messages */ LG_WARN1 = 1 << 15, /* NOTYET messages formerly walloped */ LG_WARN2 = 1 << 16, /* NOTYET messages formerly snooped */ LG_CMD_ALL = LG_CMD_ADMIN | LG_CMD_REGISTER | LG_CMD_SET | LG_CMD_DO | LG_CMD_LOGIN | LG_CMD_GET, LG_ALL = 1 << 31 - 1,/* XXX cannot use bit 31 as it would then be unequal to TOKEN_UNMATCHED */ /* aliases for use with logcommand() */ CMDLOG_ADMIN = LG_CMD_ADMIN, CMDLOG_REGISTER = LG_CMD_REGISTER | LG_REGISTER, CMDLOG_SET = LG_CMD_SET, CMDLOG_DO = LG_CMD_DO, CMDLOG_LOGIN = LG_CMD_LOGIN, CMDLOG_GET = LG_CMD_GET }; E void log_open (void); E void log_shutdown (void); E bool log_debug_enabled (void); E void log_master_set_mask (unsigned int mask); E void slog (unsigned int level, char const * const fmt, ...); E void logcommand (sourceinfo_t *si, int level, char const * const fmt, ...); E void logcommand_user (service_t *svs, user_t *source, int level, char const * const fmt, ...); E void logcommand_external (service_t *svs, char const * const type, connection_t *source, char const * const sourcedesc, myuser_t *login, int level, char const * const fmt, ...); #endif