diff options
| author | Adam <Adam@anope.org> | 2010-08-27 20:56:28 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2010-08-27 20:56:28 -0400 |
| commit | c2ddecc2b1dbc9d055166bdf296da2e4536f74f6 (patch) | |
| tree | 9b98582630a2debab628e23d4d796885f50ada74 /include | |
| parent | 73fb94c55344b6ad788c925bf13325236402891f (diff) | |
Added a new logging system
Diffstat (limited to 'include')
| -rw-r--r-- | include/bots.h | 2 | ||||
| -rw-r--r-- | include/channels.h | 4 | ||||
| -rw-r--r-- | include/config.h | 13 | ||||
| -rw-r--r-- | include/extern.h | 15 | ||||
| -rw-r--r-- | include/logger.h | 100 | ||||
| -rw-r--r-- | include/modules.h | 4 | ||||
| -rw-r--r-- | include/services.h | 41 | ||||
| -rw-r--r-- | include/users.h | 8 |
8 files changed, 130 insertions, 57 deletions
diff --git a/include/bots.h b/include/bots.h index f6b8d2e14..0a84cce71 100644 --- a/include/bots.h +++ b/include/bots.h @@ -23,6 +23,8 @@ enum BotFlag { BI_BEGIN, + /* This bot is a core bot. NickServ, ChanServ, etc */ + BI_CORE, /* This bot can only be assigned by IRCops */ BI_PRIVATE, diff --git a/include/channels.h b/include/channels.h index 8c5d83c5d..7a02b3d6b 100644 --- a/include/channels.h +++ b/include/channels.h @@ -57,7 +57,9 @@ enum ChannelFlags /* Channel still exists when emptied */ CH_PERSIST, /* If set the channel is syncing users (channel was just created) and it should not be deleted */ - CH_SYNCING + CH_SYNCING, + /* Is a services log channel */ + CH_LOGCHAN }; class CoreExport Channel : public Extensible, public Flags<ChannelFlags> diff --git a/include/config.h b/include/config.h index 8313f94d6..5d605aca5 100644 --- a/include/config.h +++ b/include/config.h @@ -465,8 +465,6 @@ class ServerConfig /* The hostname if services clients */ Anope::string ServiceHost; - /* Log channel */ - Anope::string LogChannel; /* Name of the network were on */ Anope::string NetworkName; /* The max legnth of nicks */ @@ -544,8 +542,6 @@ class ServerConfig bool UseStrictPrivMsg; /* Dump a core file if we crash */ bool DumpCore; - /* Log users connecting/existing/changing nicks */ - bool LogUsers; /* Number of seconds between consecutive uses of the REGISTER command * Not to be confused with NSRegDelay */ unsigned NickRegDelay; @@ -555,6 +551,8 @@ class ServerConfig Anope::string MLock; /* Default botmodes on channels, defaults to ao */ Anope::string BotModes; + /* THe actual modes */ + std::vector<ChannelModeStatus *> BotModeList; /* How many times to try and reconnect to the uplink before giving up */ unsigned MaxRetries; /* How long to wait between connection attempts */ @@ -562,6 +560,9 @@ class ServerConfig /* If services should hide unprivileged commands */ bool HidePrivilegedCommands; + /* A vector of our logfile options */ + std::vector<LogInfo *> LogInfos; + /* Services can use email */ bool UseMail; /* Path to the sendmail executable */ @@ -684,10 +685,6 @@ class ServerConfig Anope::string GlobalOnCycleUP; /* Super admin is allowed */ bool SuperAdmin; - /* Log things said through ACT/SAY */ - bool LogBot; - /* Log when new user max is reached */ - bool LogMaxUsers; /* Default expiry time for akills */ time_t AutokillExpiry; /* Default expiry time for chan kills */ diff --git a/include/extern.h b/include/extern.h index 4dc6cb4ba..dc4582478 100644 --- a/include/extern.h +++ b/include/extern.h @@ -153,8 +153,7 @@ E void hostserv_init(); E void introduce_user(const Anope::string &user); E bool GetCommandLineArgument(const Anope::string &name, char shortname = 0); E bool GetCommandLineArgument(const Anope::string &name, char shortname, Anope::string ¶m); -E int init_primary(int ac, char **av); -E int init_secondary(int ac, char **av); +E void Init(int ac, char **av); E Uplink *uplink_server; /**** ircd.c ****/ @@ -177,13 +176,8 @@ E const char *getstring(const NickCore *nc, int index); E const char *getstring(const User *nc, int index); E const char *getstring(int index); -/**** log.c ****/ - -E int open_log(); -E void close_log(); -E void log_perror(const char *fmt, ...) FORMAT(printf, 1, 2); -E void fatal(const char *fmt, ...) FORMAT(printf, 1, 2); -E void fatal_perror(const char *fmt, ...) FORMAT(printf, 1, 2); +/*** logger.cpp ***/ +E void InitLogChannels(ServerConfig *); /**** main.c ****/ @@ -193,7 +187,6 @@ E Anope::string services_dir; E Anope::string log_filename; E int debug; E bool readonly; -E bool LogChan; E bool nofork; E bool nothird; E bool noexpire; @@ -297,8 +290,6 @@ E unsigned GenericChannelModes, GenericUserModes; E Flags<ChannelModeName> DefMLockOn; E Flags<ChannelModeName> DefMLockOff; E std::map<ChannelModeName, Anope::string> DefMLockParams; -/* Modes to set on bots when they join the channel */ -E std::list<ChannelModeStatus *> BotModes; E void SetDefaultMLock(ServerConfig *config); /**** nickserv.c ****/ diff --git a/include/logger.h b/include/logger.h new file mode 100644 index 000000000..79a582503 --- /dev/null +++ b/include/logger.h @@ -0,0 +1,100 @@ +#ifndef LOGGER_H +#define LOGGER_H + +enum LogType +{ + LOG_ADMIN, + LOG_OVERRIDE, + LOG_COMMAND, + LOG_SERVER, + LOG_CHANNEL, + LOG_USER, + LOG_NORMAL, + LOG_TERMINAL, + LOG_RAWIO, + LOG_DEBUG, + LOG_DEBUG_2, + LOG_DEBUG_3, + LOG_DEBUG_4 +}; + +struct LogFile +{ + Anope::string filename; + + public: + std::ofstream stream; + + LogFile(const Anope::string &name); + Anope::string GetName() const; +}; + +class CoreExport Log +{ + public: + BotInfo *bi; + LogType Type; + Anope::string Category; + std::list<Anope::string> Sources; + + std::stringstream buf; + + Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = Global); + + /* LOG_COMMAND/OVERRIDE/ADMIN */ + Log(LogType type, User *u, Command *c, ChannelInfo *ci = NULL); + + /* LOG_CHANNEL */ + Log(User *u, Channel *c, const Anope::string &category = ""); + + /* LOG_USER */ + explicit Log(User *u, const Anope::string &category = ""); + + /* LOG_SERVER */ + Log(Server *s, const Anope::string &category = ""); + + Log(BotInfo *b, const Anope::string &category = ""); + + ~Log(); + + template<typename T> Log &operator<<(T val) + { + this->buf << val; + return *this; + } +}; + +class CoreExport LogInfo +{ + public: + std::list<Anope::string> Targets; + std::map<Anope::string, LogFile *> Logfiles; + std::list<Anope::string> Sources; + int LogAge; + std::list<Anope::string> Admin; + std::list<Anope::string> Override; + std::list<Anope::string> Commands; + std::list<Anope::string> Servers; + std::list<Anope::string> Users; + std::list<Anope::string> Channels; + bool Normal; + bool RawIO; + bool Debug; + + LogInfo(int logage, bool normal, bool rawio, bool debug); + + ~LogInfo(); + + void AddType(std::list<Anope::string> &list, const Anope::string &type); + + bool HasType(std::list<Anope::string> &list, const Anope::string &type) const; + + std::list<Anope::string> &GetList(LogType type); + + bool HasType(LogType Type); + + void ProcessMessage(const Log *l); +}; + +#endif // LOGGER_H + diff --git a/include/modules.h b/include/modules.h index 0d279c6c0..ebe56df48 100644 --- a/include/modules.h +++ b/include/modules.h @@ -66,7 +66,7 @@ if (true) \ } \ catch (const ModuleException &modexcept) \ { \ - Alog() << "Exception caught: " << modexcept.GetReason(); \ + Log() << "Exception caught: " << modexcept.GetReason(); \ } \ _i = safei; \ } \ @@ -98,7 +98,7 @@ if (true) \ } \ catch (const ModuleException &modexcept) \ { \ - Alog() << "Exception caught: " << modexcept.GetReason(); \ + Log() << "Exception caught: " << modexcept.GetReason(); \ } \ _i = safei; \ } \ diff --git a/include/services.h b/include/services.h index 2cda56a31..a0c701b95 100644 --- a/include/services.h +++ b/include/services.h @@ -181,6 +181,7 @@ extern "C" void __pfnBkCheck() {} /* Pull in the various bits of STL */ #include <iostream> +#include <fstream> #include <sstream> #include <string> #include <map> @@ -253,6 +254,14 @@ class CoreException : public std::exception } }; +class FatalException : public CoreException +{ + public: + FatalException(const Anope::string &reason = "") : CoreException(reason) { } + + virtual ~FatalException() throw() { } +}; + class ModuleException : public CoreException { public: @@ -939,6 +948,7 @@ class ServerConfig; #include "operserv.h" #include "mail.h" #include "servers.h" +#include "logger.h" #include "config.h" class CoreExport IRCDProto @@ -1039,10 +1049,6 @@ class CoreExport IRCDProto virtual void SetAutoIdentificationToken(User *u) { } }; -class IRCDTS6Proto : public IRCDProto -{ -}; - /*************************************************************************/ struct Uplink @@ -1055,33 +1061,6 @@ struct Uplink Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { } }; -enum LogLevel -{ - LOG_NORMAL, - LOG_TERMINAL, - LOG_DEBUG, - LOG_DEBUG_2, - LOG_DEBUG_3, - LOG_DEBUG_4 -}; - -class CoreExport Alog -{ - private: - std::stringstream buf; - LogLevel Level; - public: - Alog(LogLevel val = LOG_NORMAL); - ~Alog(); - template<typename T> Alog &operator<<(T val) - { - buf << val; - return *this; - } -}; - -/*************************************************************************/ - #include "timers.h" /** Timer for colliding nicks to force people off of nicknames diff --git a/include/users.h b/include/users.h index 40e98b114..e65068f33 100644 --- a/include/users.h +++ b/include/users.h @@ -76,10 +76,12 @@ class CoreExport User : public Extensible /** Create a new user object, initialising necessary fields and * adds it to the hash * - * @param nick The nickname of the user. - * @param uid The unique identifier of the user. + * @param snick The nickname of the user. + * @param sident The username of the user + * @param shost The hostname of the user + * @param suid The unique identifier of the user. */ - User(const Anope::string &nick, const Anope::string &uid); + User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &suid); /** Destroy a user. */ |
