diff options
author | Adam <Adam@anope.org> | 2017-01-23 12:35:14 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2017-01-23 12:35:14 -0500 |
commit | 16ca76c2e7ab287e480185fbb03a0bb438351eda (patch) | |
tree | dfb25534afa2352b65b2ee707086cb5eecc96fbb | |
parent | ff030c1eb7c3764f9add2a689479e84d616cabcb (diff) |
Make log system use newer format strings
Also allow log messages to be translatable
169 files changed, 1689 insertions, 1161 deletions
diff --git a/include/anope.h b/include/anope.h index 02a8c3fef..07e275e2f 100644 --- a/include/anope.h +++ b/include/anope.h @@ -148,6 +148,7 @@ namespace Anope inline void push_back(char c) { return this->_string.push_back(c); } inline string& insert(const_iterator p, char c) { this->_string.insert(p, c); return *this; } + inline string& insert(size_t pos, const string& str) { this->_string.insert(pos, str._string); return *this; } inline string& append(const string &s) { this->_string.append(s.str()); return *this; } inline string& append(const char *s, size_t n) { this->_string.append(s, n); return *this; } @@ -550,6 +551,8 @@ namespace Anope * @param len The length of the string returned */ extern CoreExport Anope::string Random(size_t len); + + extern Logger Logger; } /** sepstream allows for splitting token separated lists. @@ -732,7 +735,8 @@ operator>>(std::istream &is, T& t) /** Convert something to a string */ -template<typename T> inline Anope::string stringify(const T &x) +template<typename T> +inline Anope::string stringify(const T &x) { std::ostringstream stream; @@ -742,6 +746,12 @@ template<typename T> inline Anope::string stringify(const T &x) return stream.str(); } +template<> +inline Anope::string stringify(const Anope::string &str) +{ + return str; +} + template<typename T> inline void convert(const Anope::string &s, T &x, Anope::string &leftover, bool failIfLeftoverChars = true) { leftover.clear(); @@ -819,39 +829,47 @@ inline kwarg operator"" _kw(const char *literal, size_t n) return { literal }; } -struct FormatInfo +class FormatInfo { Anope::string format; std::vector<kwarg> parameters; unsigned int pos = 0; + public: FormatInfo(const Anope::string &fmt, size_t size) : format(fmt), parameters(size) { } template<typename T> - void Add(T& arg) + void Add(const T& arg) { - parameters[pos] = kwarg{ stringify(pos).c_str() } = stringify(arg); - ++pos; + kwarg k = kwarg{ stringify(pos), stringify(arg) }; + Add(k); } + void AddArgs() { } + template<typename Arg, typename... Args> - void Format(Arg &&arg, Args&&... args) + void AddArgs(Arg &&arg, Args&&... args) { Add(arg); - Format(std::forward<Args>(args)...); + AddArgs(std::forward<Args>(args)...); } - void Format() - { - for (kwarg& arg : parameters) - format = format.replace_all_cs("{" + arg.name + "}", arg.value); - } + const kwarg *GetKwarg(const Anope::string &name) const; + + void Format(); + + const Anope::string &GetFormat() const; }; template<> -inline void FormatInfo::Add(kwarg &arg) +inline void FormatInfo::Add(const kwarg &arg) { - parameters[pos++] = arg; + unsigned int p = pos++; + + if (p >= parameters.size()) + parameters.resize(p + 1); + + parameters[p] = arg; } namespace Anope @@ -860,8 +878,9 @@ namespace Anope inline Anope::string Format(const Anope::string &format, Args&&... args) { FormatInfo fi(format, sizeof...(Args)); - fi.Format(std::forward<Args>(args)...); - return fi.format; + fi.AddArgs(std::forward<Args>(args)...); + fi.Format(); + return fi.GetFormat(); } } diff --git a/include/bots.h b/include/bots.h index 928107ef3..6432a15b3 100644 --- a/include/bots.h +++ b/include/bots.h @@ -37,7 +37,8 @@ class CoreExport ServiceBot : public LocalUser /* Modes the bot should have as configured in service:modes */ Anope::string botmodes; /* Whether or not this bot is introduced to the network */ - bool introduced; + bool introduced = false; + Logger logger; /** Create a new bot. * @param nick The nickname to assign to the bot. @@ -140,7 +141,7 @@ class BotInfo : public Serialize::Object public: static constexpr const char *const NAME = "botinfo"; - ServiceBot *bot; + ServiceBot *bot = nullptr; Configuration::Block *conf = nullptr; using Serialize::Object::Object; diff --git a/include/channels.h b/include/channels.h index 31fa582c4..49daf6f7e 100644 --- a/include/channels.h +++ b/include/channels.h @@ -58,9 +58,9 @@ class CoreExport Channel : public Base, public Extensible /* When the channel was created */ time_t creation_time; /* If the channel has just been created in a netjoin */ - bool syncing; + bool syncing = false; /* Is configured in the conf as a channel bots should be in */ - bool botchannel; + bool botchannel = false; /* Users in the channel */ typedef std::map<User *, ChanUserContainer *> ChanUserList; @@ -74,15 +74,17 @@ class CoreExport Channel : public Base, public Extensible * This is the time the topic was *originally set*. When we restore the topic we want to change the TS back * to this, but we can only do this on certain IRCds. */ - time_t topic_ts; + time_t topic_ts = 0; /* The actual time the topic was set, probably close to Anope::CurTime */ - time_t topic_time; + time_t topic_time = 0; - time_t server_modetime; /* Time of last server MODE */ - time_t chanserv_modetime; /* Time of last check_modes() */ - int16_t server_modecount; /* Number of server MODEs this second */ - int16_t chanserv_modecount; /* Number of check_mode()'s this sec */ - int16_t bouncy_modes; /* Did we fail to set modes here? */ + time_t server_modetime = 0; /* Time of last server MODE */ + time_t chanserv_modetime = 0; /* Time of last check_modes() */ + int16_t server_modecount = 0; /* Number of server MODEs this second */ + int16_t chanserv_modecount = 0; /* Number of check_mode()'s this sec */ + int16_t bouncy_modes = 0; /* Did we fail to set modes here? */ + + Logger logger; private: /** Constructor @@ -96,6 +98,11 @@ class CoreExport Channel : public Base, public Extensible */ ~Channel(); + /** Gets the channels name + * @return the channel name + */ + const Anope::string &GetName() const; + /** Call if we need to unset all modes and clear all user status (internally). * Only useful if we get a SJOIN with a TS older than what we have here */ diff --git a/include/commands.h b/include/commands.h index 8cdb0d544..5431df7a5 100644 --- a/include/commands.h +++ b/include/commands.h @@ -86,6 +86,9 @@ class CoreExport CommandSource const Anope::string &GetNick() const; User *GetUser(); NickServ::Account *GetAccount(); + Anope::string GetSource(); + const Anope::string &GetCommand() const; + ChanServ::AccessGroup AccessFor(ChanServ::Channel *ci); bool IsFounder(ChanServ::Channel *ci); @@ -111,11 +114,13 @@ class CoreExport Command : public Service Anope::string desc; std::vector<Anope::string> syntax; /* Allow unregistered users to use this command */ - bool allow_unregistered; + bool allow_unregistered = false; /* Command requires that a user is executing it */ - bool require_user; + bool require_user = false; public: + static constexpr const char *NAME = "Command"; + /* Maximum paramaters accepted by this command */ size_t max_params; /* Minimum parameters required to use this command */ @@ -124,9 +129,8 @@ class CoreExport Command : public Service /* Module which owns us */ Module *module; - static constexpr const char *NAME = "Command"; + Logger logger; - protected: /** Create a new command. * @param owner The owner of the command * @param sname The command name @@ -136,10 +140,8 @@ class CoreExport Command : public Service */ Command(Module *owner, const Anope::string &sname, size_t min_params, size_t max_params = 0); - public: virtual ~Command(); - protected: void SetDesc(const Anope::string &d); void ClearSyntax(); @@ -148,7 +150,6 @@ class CoreExport Command : public Service void AllowUnregistered(bool b); void RequireUser(bool b); - public: void SendSyntax(CommandSource &); bool AllowUnregistered() const; bool RequireUser() const; diff --git a/include/defs.h b/include/defs.h index b25183062..989ce3e5b 100644 --- a/include/defs.h +++ b/include/defs.h @@ -42,6 +42,7 @@ class IRCDProto; class ListenSocket; class Log; class LogInfo; +class Logger; namespace NickServ { class Account; diff --git a/include/event.h b/include/event.h index fcc292aea..85e406795 100644 --- a/include/event.h +++ b/include/event.h @@ -1074,7 +1074,7 @@ namespace Event /** Called when a message is logged * @param l The log message */ - virtual void OnLog(::Log *l) anope_abstract; + virtual void OnLog(Logger *l) anope_abstract; }; struct CoreExport LogMessage : Events @@ -1089,7 +1089,7 @@ namespace Event * @param l The log message * @param msg The final formatted message, derived from 'l' */ - virtual void OnLogMessage(LogInfo *li, const ::Log *l, const Anope::string &msg) anope_abstract; + virtual void OnLogMessage(LogInfo *li, const Logger *l, const Anope::string &msg) anope_abstract; }; struct CoreExport CheckModes : Events diff --git a/include/extensible.h b/include/extensible.h index 2e1079631..cc18b5e5c 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -137,7 +137,7 @@ T* Extensible::GetExt(const Anope::string &name) if (ref) return ref->Get(this); - Log(LOG_DEBUG) << "GetExt for nonexistent type " << name << " on " << static_cast<const void *>(this); + Anope::Logger.Debug("GetExt for nonexistent type {0} on {1}", name, static_cast<void *>(this)); return NULL; } @@ -151,7 +151,7 @@ T* Extensible::Extend(const Anope::string &name, const T &what) return ref->Get(this); } - Log(LOG_DEBUG) << "Extend for nonexistent type " << name << " on " << static_cast<void *>(this); + Anope::Logger.Debug("Extend for nonexistent type {0} on {1}", name, static_cast<void *>(this)); return NULL; } @@ -162,6 +162,6 @@ void Extensible::Shrink(const Anope::string &name) if (ref) ref->Unset(this); else - Log(LOG_DEBUG) << "Shrink for nonexistent type " << name << " on " << static_cast<void *>(this); + Anope::Logger.Debug("Shrink for nonexistent type {0} on {1}", name, static_cast<void *>(this)); } diff --git a/include/logger.h b/include/logger.h index f3b00068b..d368eb142 100644 --- a/include/logger.h +++ b/include/logger.h @@ -21,28 +21,33 @@ #include "anope.h" #include "defs.h" +#include "language.h" -enum LogType +enum class LogType { + NORMAL, /* Used whenever an administrator uses an administrative comand */ - LOG_ADMIN, + ADMIN, /* Used whenever an administrator overides something, such as adding * access to a channel where they don't have permission to. */ - LOG_OVERRIDE, + OVERRIDE, /* Any other command usage */ - LOG_COMMAND, - LOG_SERVER, - LOG_CHANNEL, - LOG_USER, - LOG_MODULE, - LOG_NORMAL, - LOG_TERMINAL, - LOG_RAWIO, - LOG_DEBUG, - LOG_DEBUG_2, - LOG_DEBUG_3, - LOG_DEBUG_4 + COMMAND, + SERVER, + CHANNEL, + USER, + MODULE +}; + +enum class LogLevel +{ + NORMAL, + TERMINAL, + RAWIO, + DEBUG, + DEBUG_2, + DEBUG_3 }; struct LogFile @@ -55,96 +60,170 @@ struct LogFile const Anope::string &GetName() const; }; -/* Represents a single log message */ -class CoreExport Log +/* Configured in the configuration file, actually does the message logging */ +class CoreExport LogInfo { public: - /* Bot that should log this message */ - ServiceBot *bi; - /* For commands, the user executing the command, but might not always exist */ - User *u; - /* For commands, the account executing the command, but will not always exist */ - NickServ::Account *nc; - /* For commands, the command being executed */ - Command *c; - /* For commands, the command source */ - CommandSource *source; - /* Used for LOG_CHANNEL */ - Channel *chan; - /* For commands, the channel the command was executed on, will not always exist */ - ChanServ::Channel *ci; - /* For LOG_SERVER */ - Server *s; - /* For LOG_MODULE */ - Module *m; - LogType type; - Anope::string category; + ServiceBot *bot = nullptr; + std::vector<Anope::string> targets; + std::vector<LogFile *> logfiles; + int last_day = 0; + std::vector<Anope::string> sources; + int log_age = 0; + std::vector<Anope::string> admin; + std::vector<Anope::string> override; + std::vector<Anope::string> commands; + std::vector<Anope::string> servers; + std::vector<Anope::string> users; + std::vector<Anope::string> channels; + std::vector<Anope::string> normal; + bool raw_io = false; + bool debug = false; - std::stringstream buf; + LogInfo(int logage, bool rawio, bool debug); - Log(LogType type = LOG_NORMAL, const Anope::string &category = "", ServiceBot *bi = NULL); + ~LogInfo(); + + void OpenLogFiles(); - /* LOG_COMMAND/OVERRIDE/ADMIN */ - Log(LogType type, CommandSource &source, Command *c, ChanServ::Channel *ci = NULL); + bool HasType(LogType ltype, LogLevel level, const Anope::string &type) const; - /* LOG_CHANNEL */ - Log(User *u, Channel *c, const Anope::string &category = ""); + void ProcessMessage(const Logger *l, const Anope::string &message); +}; - /* LOG_USER */ - Log(User *u, const Anope::string &category = "", ServiceBot *bi = NULL); +class Logger +{ + friend class LogInfo; - /* LOG_SERVER */ - Log(Server *s, const Anope::string &category = "", ServiceBot *bi = NULL); + LogType type = LogType::NORMAL; + LogLevel level = LogLevel::NORMAL; - Log(ServiceBot *b, const Anope::string &category = ""); + /* Object logger is attached to */ + Module *module = nullptr; + Command *command = nullptr; + ServiceBot *bot = nullptr; + Server *server = nullptr; - Log(Module *m, const Anope::string &category = "", ServiceBot *bi = NULL); + /* Logger category */ + Anope::string category; + /* Non formatted message */ + Anope::string raw_message; - ~Log(); + /* Sources */ + User *user = nullptr; + NickServ::Account *account = nullptr; + Channel *channel = nullptr; + ChanServ::Channel *ci = nullptr; + CommandSource *source = nullptr; - private: Anope::string FormatSource() const; - Anope::string FormatCommand() const; - - public: Anope::string BuildPrefix() const; + void LogMessage(const Anope::string &message); + void InsertVariables(FormatInfo &fi); - template<typename T> Log &operator<<(T val) + template<typename... Args> + Anope::string Format(const Anope::string &message, Args&&... args) { - this->buf << val; - return *this; + FormatInfo fi(message, sizeof...(Args)); + fi.AddArgs(std::forward<Args>(args)...); + InsertVariables(fi); + fi.Format(); + return fi.GetFormat(); } -}; -/* Configured in the configuration file, actually does the message logging */ -class CoreExport LogInfo -{ public: - ServiceBot *bot; - std::vector<Anope::string> targets; - std::vector<LogFile *> logfiles; - int last_day; - std::vector<Anope::string> sources; - int log_age; - std::vector<Anope::string> admin; - std::vector<Anope::string> override; - std::vector<Anope::string> commands; - std::vector<Anope::string> servers; - std::vector<Anope::string> users; - std::vector<Anope::string> channels; - std::vector<Anope::string> normal; - bool raw_io; - bool debug; + Logger() = default; + Logger(Module *m) : type(LogType::MODULE), module(m) { } + Logger(Command *c) : type(LogType::COMMAND), command(c) { } + Logger(ServiceBot *b) : bot(b) { } + Logger(Channel *c) : type(LogType::CHANNEL), channel(c) { } + Logger(User *u) : type(LogType::USER), user(u) { } + Logger(Server *s) : type(LogType::SERVER), server(s) { } + + LogType GetType() const; + LogLevel GetLevel() const; + + Module *GetModule() const; + Command *GetCommand() const; + ServiceBot *GetBot() const; + Server *GetServer() const; + + User *GetUser() const; + void SetUser(User *); + + NickServ::Account *GetAccount() const; + void SetAccount(NickServ::Account *); + + Channel *GetChannel() const; + void SetChannel(Channel *); + + ChanServ::Channel *GetCi() const; + void SetCi(ChanServ::Channel *); + + CommandSource *GetSource() const; + void SetSource(CommandSource *); + + Logger Category(const Anope::string &c) const; + Logger User(class User *u) const; + Logger Channel(class Channel *c) const; + Logger Channel(ChanServ::Channel *c) const; + Logger Source(CommandSource *s) const; + Logger Bot(ServiceBot *bot) const; + Logger Bot(const Anope::string &name) const; + + template<typename... Args> void Log(LogLevel level, const Anope::string &message, Args&&... args) + { + Logger l = *this; + l.raw_message = message; + l.level = level; - LogInfo(int logage, bool rawio, bool debug); + Anope::string translated = Language::Translate(message); + l.LogMessage(l.Format(translated, std::forward<Args>(args)...)); + } - ~LogInfo(); + template<typename... Args> void Command(LogType type, CommandSource &source, ChanServ::Channel *ci, const Anope::string &message, Args&&... args) + { + Logger l = *this; + l.SetSource(&source); + l.SetCi(ci); - void OpenLogFiles(); + Anope::string translated = Language::Translate(message); + l.LogMessage(l.Format(translated, std::forward<Args>(args)...)); + } + + template<typename... Args> void Command(LogType type, CommandSource &source, const Anope::string &message, Args&&... args) + { + Command(type, source, nullptr, message, std::forward<Args>(args)...); + } - bool HasType(LogType ltype, const Anope::string &type) const; + template<typename... Args> void Log(const Anope::string &message, Args&&... args) + { + Log(LogLevel::NORMAL, message, std::forward<Args>(args)...); + } + + template<typename... Args> void Terminal(const Anope::string &message, Args&&... args) + { + Log(LogLevel::TERMINAL, message, std::forward<Args>(args)...); + } + + template<typename... Args> void RawIO(const Anope::string &message, Args&&... args) + { + Log(LogLevel::RAWIO, message, std::forward<Args>(args)...); + } - /* Logs the message l if configured to */ - void ProcessMessage(const Log *l); + template<typename... Args> void Debug(const Anope::string &message, Args&&... args) + { + Log(LogLevel::DEBUG, message, std::forward<Args>(args)...); + } + + template<typename... Args> void Debug2(const Anope::string &message, Args&&... args) + { + Log(LogLevel::DEBUG_2, message, std::forward<Args>(args)...); + } + + template<typename... Args> void Debug3(const Anope::string &message, Args&&... args) + { + Log(LogLevel::DEBUG_3, message, std::forward<Args>(args)...); + } }; diff --git a/include/modules.h b/include/modules.h index ff9303c4f..eb3b15094 100644 --- a/include/modules.h +++ b/include/modules.h @@ -212,6 +212,8 @@ class CoreExport Module : public Extensible */ Anope::string author; + Logger logger; + /** Creates and initialises a new module. * @param modname The module name * @param loadernick The nickname of the user loading the module. @@ -223,6 +225,8 @@ class CoreExport Module : public Extensible */ virtual ~Module(); + const Anope::string &GetName() const; + /** Toggles the permanent flag on a module. If a module is permanent, * then it may not be unloaded. * diff --git a/include/modules/dns.h b/include/modules/dns.h index e98826ce7..5eb0f3950 100644 --- a/include/modules/dns.h +++ b/include/modules/dns.h @@ -176,7 +176,7 @@ namespace DNS */ void Tick(time_t) override { - Log(LOG_DEBUG_2) << "Resolver: timeout for query " << this->name; + Anope::Logger.Debug2("Resolver: timeout for query {0}", this->name); Query rr(*this); rr.error = ERROR_TIMEDOUT; this->OnError(&rr); diff --git a/include/modules/redis.h b/include/modules/redis.h index dc8c1e75f..c26ad194f 100644 --- a/include/modules/redis.h +++ b/include/modules/redis.h @@ -54,14 +54,16 @@ namespace Redis class Interface { - public: Module *owner; + public: Interface(Module *m) : owner(m) { } virtual ~Interface() = default; + Module *GetOwner() const { return owner; } + virtual void OnResult(const Reply &r) anope_abstract; - virtual void OnError(const Anope::string &error) { Log(owner) << error; } + virtual void OnError(const Anope::string &error) { owner->logger.Log(error); } }; class FInterface : public Interface diff --git a/include/protocol.h b/include/protocol.h index 4dc115fe6..89d337594 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -112,7 +112,8 @@ public: if (!sender) { - Log(LOG_DEBUG) << "No message sender for type " << T::NAME; + const char *const name = T::NAME; + Anope::Logger.Debug("No message sender for type {0}", name); return; } diff --git a/include/serialize.h b/include/serialize.h index 67be96c0c..90aedc7ae 100644 --- a/include/serialize.h +++ b/include/serialize.h @@ -298,7 +298,7 @@ class Serialize::Type : public Base if (s->GetSerializableType() != this) { - Log(LOG_DEBUG) << "Mismatch for required id " << id << ", is of type " << s->GetSerializableType()->GetName() << " but wants " << this->GetName(); + Anope::Logger.Debug("Mismatch for required id {0}, is of type {1} but wants {2}", id, s->GetSerializableType()->GetName(), this->GetName()); return nullptr; } @@ -649,7 +649,6 @@ class Serialize::Field : public CommonFieldBase<TypeImpl, T> } catch (const ConvertException &) { - Log(LOG_DEBUG) << "Unable to stringify " << t; return ""; } } @@ -737,7 +736,7 @@ class Serialize::ObjectField : public CommonFieldBase<TypeImpl, T> Serialize::TypeBase *base = Serialize::TypeBase::Find(type); if (base == nullptr) { - Log(LOG_DEBUG_2) << "OnSerializeGetSerializable returned unknown type " << type; + Anope::Logger.Debug2("OnSerializeGetSerializable returned unknown type {0}", type); return nullptr; } @@ -894,7 +893,7 @@ T Serialize::New() if (type == nullptr) { - Log(LOG_DEBUG) << "Serialize::New with unknown type " << name; + Anope::Logger.Debug("Serialize::New with unknown type {0}", name); return nullptr; } @@ -908,7 +907,7 @@ inline std::vector<Serialize::Object *> Serialize::Object::GetRefs(Serialize::Ty if (types.empty()) { - Log(LOG_DEBUG) << "GetRefs for unknown type on #" << this->id << " type " << s_type->GetName() << " named " << type->GetName(); + Anope::Logger.Debug("GetRefs for unknown type on #{0} type {1} named {2}", this->id, s_type->GetName(), type->GetName()); return objs; } @@ -929,7 +928,7 @@ std::vector<T> Serialize::Object::GetRefs() if (types.empty()) { - Log(LOG_DEBUG) << "GetRefs for unknown type on #" << this->id << " type " << s_type->GetName() << " named " << name; + Anope::Logger.Debug("GetRefs for unknown type on #{0} type {1} named {2}", this->id, s_type->GetName(), name); return objs; } @@ -947,7 +946,7 @@ void Serialize::Object::SetS(const Anope::string &name, const T &what) FieldBase *field = s_type->GetField(name); if (field == nullptr) { - Log(LOG_DEBUG) << "Set for unknown field " << name << " on " << s_type->GetName(); + Anope::Logger.Debug("Set for unknown field {0} on {1}", name, s_type->GetName()); return; } @@ -961,7 +960,7 @@ void Serialize::Object::UnsetS(const Anope::string &name) FieldBase *field = s_type->GetField(name); if (field == nullptr) { - Log(LOG_DEBUG) << "Unset for unknown field " << name << " on " << s_type->GetName(); + Anope::Logger.Debug("Unset for unknown field {0} on {1}", name, s_type->GetName()); return; } @@ -974,7 +973,7 @@ inline bool Serialize::Object::HasFieldS(const Anope::string &name) FieldBase *field = s_type->GetField(name); if (field == nullptr) { - Log(LOG_DEBUG) << "HasField for unknown field " << name << " on " << s_type->GetName(); + Anope::Logger.Debug("HasField for unknown field {0} on {1}", name, s_type->GetName()); return false; } diff --git a/include/servers.h b/include/servers.h index 64a265a85..27273f7aa 100644 --- a/include/servers.h +++ b/include/servers.h @@ -78,7 +78,7 @@ class CoreExport Server : public Extensible * @param sid Server sid/numeric * @param jupe If the server is juped */ - Server(Server *uplink, const Anope::string &name, unsigned hops, const Anope::string &description, const Anope::string &sid = "", bool jupe = false); + Server(Server *uplink, const Anope::string &name, unsigned int hops, const Anope::string &description, const Anope::string &sid = "", bool jupe = false); private: /** Destructor @@ -87,7 +87,9 @@ class CoreExport Server : public Extensible public: /* Number of users on the server */ - unsigned users; + unsigned int users; + + Logger logger; void Burst(); diff --git a/include/users.h b/include/users.h index be4ee2a39..de9cc5b42 100644 --- a/include/users.h +++ b/include/users.h @@ -71,6 +71,8 @@ class CoreExport User : public virtual Base, public virtual Extensible, public C public: UserType type = UserType::USER; + Logger logger; + /* User's current nick */ Anope::string nick; @@ -367,12 +369,11 @@ class CoreExport User : public virtual Base, public virtual Extensible, public C /* Returns a mask that will most likely match any address the * user will have from that location. For IP addresses, wildcards the - * appropriate subnet mask (e.g. 35.1.1.1 -> 35.*; 128.2.1.1 -> 128.2.*); - * for named addresses, wildcards the leftmost part of the name unless the - * name only contains two parts. If the username begins with a ~, delete - * it. + * last octet (e.g. 35.1.1.1 -> 35.1.1.*). for named addresses, wildcards + * the leftmost part of the name unless the name only contains two parts. + * If the username begins with a ~, replace with *. */ - Anope::string Mask() const; + Anope::string WildMask() const; /** Notes the usage of an incorrect password. If too many * incorrect passwords are used the user might be killed. diff --git a/modules/botserv/assign.cpp b/modules/botserv/assign.cpp index eca103e9f..db368c75e 100644 --- a/modules/botserv/assign.cpp +++ b/modules/botserv/assign.cpp @@ -80,7 +80,7 @@ class CommandBSAssign : public Command } bool override = !access.HasPriv("ASSIGN"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << bi->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to assign {0}"), bi->nick); bi->Assign(source.GetUser(), ci); source.Reply(_("Bot \002{0}\002 has been assigned to \002{1}\002."), bi->nick, ci->GetName()); @@ -147,7 +147,7 @@ class CommandBSUnassign : public Command } bool override = !access.HasPriv("ASSIGN"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << ci->GetBot()->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to unassign {0}"), ci->GetBot()->nick); ServiceBot *bi = ci->GetBot(); bi->UnAssign(source.GetUser(), ci); @@ -192,7 +192,7 @@ class CommandBSSetNoBot : public Command if (value.equals_ci("ON")) { - Log(LOG_ADMIN, source, this, ci) << "to enable nobot"; + logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} to enable nobot")); ci->SetS<bool>("BS_NOBOT", true); if (ci->GetBot()) @@ -201,7 +201,7 @@ class CommandBSSetNoBot : public Command } else if (value.equals_ci("OFF")) { - Log(LOG_ADMIN, source, this, ci) << "to disable nobot"; + logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} to disable nobot")); ci->UnsetS<bool>("BS_NOBOT"); source.Reply(_("No-bot mode is now \002off\002 for \002{0}\002."), ci->GetName()); diff --git a/modules/botserv/autoassign.cpp b/modules/botserv/autoassign.cpp index 3bb6dce64..861d97f6f 100644 --- a/modules/botserv/autoassign.cpp +++ b/modules/botserv/autoassign.cpp @@ -37,7 +37,7 @@ class BSAutoAssign : public Module ServiceBot *bi = ServiceBot::Find(bot, true); if (bi == NULL) { - Log(this) << "bs_autoassign is configured to assign bot " << bot << ", but it does not exist?"; + logger.Log("bs_autoassign is configured to assign bot {0}, but it does not exist?", bot); return; } diff --git a/modules/botserv/badwords.cpp b/modules/botserv/badwords.cpp index 754e202a7..071414ac4 100644 --- a/modules/botserv/badwords.cpp +++ b/modules/botserv/badwords.cpp @@ -144,9 +144,9 @@ class CommandBSBadwords : public Command void DoList(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word) { bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST"; - ListFormatter list(source.GetAccount()); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to list badwords")); + ListFormatter list(source.GetAccount()); list.AddColumn(_("Number")).AddColumn(_("Word")).AddColumn(_("Type")); if (!badwords->GetBadWordCount(ci)) @@ -244,7 +244,7 @@ class CommandBSBadwords : public Command } bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ADD " << realword; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0}"), realword); badwords->AddBadWord(ci, realword, bwtype); source.Reply(_("\002{0}\002 added to \002{1}\002 bad words list."), realword, ci->GetName()); @@ -271,7 +271,8 @@ class CommandBSBadwords : public Command if (!num || num > badwords->GetBadWordCount(ci)) return; - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "DEL " << badwords->GetBadWord(ci, num - 1)->GetWord(); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to remove {0}"), badwords->GetBadWord(ci, num - 1)->GetWord()); + ++deleted; badwords->EraseBadWord(ci, num - 1); }, @@ -304,7 +305,7 @@ class CommandBSBadwords : public Command return; } - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "DEL " << bw->GetWord(); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to remove {3}"), bw->GetWord()); source.Reply(_("\002{0}\002 deleted from \002{1}\002 bad words list."), bw->GetWord(), ci->GetName()); @@ -315,7 +316,7 @@ class CommandBSBadwords : public Command void DoClear(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "CLEAR"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the badwords list")); badwords->ClearBadWords(ci); source.Reply(_("Bad words list is now empty.")); diff --git a/modules/botserv/bot.cpp b/modules/botserv/bot.cpp index 082bd6337..4eb5d2069 100644 --- a/modules/botserv/bot.cpp +++ b/modules/botserv/bot.cpp @@ -103,7 +103,7 @@ class CommandBSBot : public Command bi->bi = botinfo; botinfo->bot = bi; - Log(LOG_ADMIN, source, this) << "ADD " << bi->GetMask() << " " << bi->realname; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add bot {0} {1}"), bi->GetMask(), bi->realname); source.Reply(_("\002{0}!{1}@{2}\002 (\002{3}\002) added to the bot list."), bi->nick, bi->GetIdent(), bi->host, bi->realname); @@ -266,8 +266,10 @@ class CommandBSBot : public Command if (!user.empty()) bi->OnKill(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to change bot {0} to {1} {2}"), + oldnick, bi->GetMask(), bi->realname); + source.Reply(_("Bot \002{0}\002 has been changed to \002{1}!{2}@{3}\002 (\002{4}\002)."), oldnick, bi->nick, bi->GetIdent(), bi->host, bi->realname); - Log(LOG_ADMIN, source, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; EventManager::Get()->Dispatch(&Event::BotChange::OnBotChange, bi); } @@ -297,7 +299,7 @@ class CommandBSBot : public Command EventManager::Get()->Dispatch(&Event::BotDelete::OnBotDelete, bi); - Log(LOG_ADMIN, source, this) << "DEL " << bi->nick; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to delete bot {0}"), bi->nick); source.Reply(_("Bot \002{0}\002 has been deleted."), bi->nick); delete bi; diff --git a/modules/botserv/control.cpp b/modules/botserv/control.cpp index 448a28baf..1785e65e9 100644 --- a/modules/botserv/control.cpp +++ b/modules/botserv/control.cpp @@ -75,7 +75,7 @@ class CommandBSSay : public Command ci->GetBot()->lastmsg = Anope::CurTime; bool override = !source.AccessFor(ci).HasPriv("SAY"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to say: " << text; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to say: {0}"), text); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -145,7 +145,7 @@ class CommandBSAct : public Command ci->GetBot()->lastmsg = Anope::CurTime; bool override = !source.AccessFor(ci).HasPriv("SAY"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to say: " << message; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} to say: {0}"), message); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/botserv/kick.cpp b/modules/botserv/kick.cpp index a32656f62..745525fa3 100644 --- a/modules/botserv/kick.cpp +++ b/modules/botserv/kick.cpp @@ -637,12 +637,12 @@ class CommandBSKickBase : public Command source.Reply(_("Bot will now kick for \002{0}\002."), optname); bool override = !source.AccessFor(ci).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable the " << optname << " kicker"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable the {0} kicker"), optname); } else if (param.equals_ci("OFF")) { bool override = !source.AccessFor(ci).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable the " << optname << " kicker"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable the {0} kicker"), optname); (kd->*setter)(false); (kd->*ttbsetter)(0); @@ -1099,7 +1099,7 @@ class CommandBSSetDontKickOps : public Command if (params[1].equals_ci("ON")) { bool override = !access.HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickops"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable dontkickops")); kd->SetDontKickOps(true); source.Reply(_("Bot \002won't kick ops\002 on channel \002{0}\002."), ci->GetName()); @@ -1107,7 +1107,7 @@ class CommandBSSetDontKickOps : public Command else if (params[1].equals_ci("OFF")) { bool override = !access.HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickops"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable dontkickops")); kd->SetDontKickOps(false); source.Reply(_("Bot \002will kick ops\002 on channel \002{0}\002."), ci->GetName()); @@ -1165,7 +1165,7 @@ class CommandBSSetDontKickVoices : public Command if (params[1].equals_ci("ON")) { bool override = !access.HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickvoices"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable dontkickvoices")); kd->SetDontKickVoices(true); source.Reply(_("Bot \002won't kick voices\002 on channel %s."), ci->GetName().c_str()); @@ -1173,7 +1173,7 @@ class CommandBSSetDontKickVoices : public Command else if (params[1].equals_ci("OFF")) { bool override = !access.HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickvoices"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable dontkickvoices")); kd->SetDontKickVoices(false); source.Reply(_("Bot \002will kick voices\002 on channel %s."), ci->GetName().c_str()); @@ -1200,15 +1200,8 @@ struct BanData struct Data { Anope::string mask; - time_t last_use; - int16_t ttb[TTB_SIZE]; - - Data() - { - last_use = 0; - for (int i = 0; i < TTB_SIZE; ++i) - this->ttb[i] = 0; - } + time_t last_use = 0; + int16_t ttb[TTB_SIZE] = { 0 }; }; private: @@ -1269,7 +1262,7 @@ class BanDataPurger : public Timer void Tick(time_t) override { - Log(LOG_DEBUG) << "bs_main: Running bandata purger"; + this->GetOwner()->logger.Debug("Running bandata purger"); for (channel_map::iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) { diff --git a/modules/botserv/set.cpp b/modules/botserv/set.cpp index 6ab429d97..6845281cb 100644 --- a/modules/botserv/set.cpp +++ b/modules/botserv/set.cpp @@ -140,7 +140,7 @@ class CommandBSSetBanExpire : public Command ci->SetBanExpire(t); bool override = !access.HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to change banexpire to " << arg; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to change banexpire to {0}"), arg); if (!t) source.Reply(_("Bot bans will no longer automatically expire.")); diff --git a/modules/chanserv/access.cpp b/modules/chanserv/access.cpp index 967df9025..6ad67733e 100644 --- a/modules/chanserv/access.cpp +++ b/modules/chanserv/access.cpp @@ -213,7 +213,8 @@ class CommandCSAccess : public Command EventManager::Get()->Dispatch(&Event::AccessAdd::OnAccessAdd, ci, source, access); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << " with level " << level; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0} with level {1}"), mask, level); + if (p != NULL) source.Reply(_("\002{0}\002 added to the access list of \002{1}\002 with privilege \002{2}\002 (level \002{3}\002)."), access->Mask(), ci->GetName(), p->name, level); else @@ -283,7 +284,7 @@ class CommandCSAccess : public Command source.Reply(_("There are no entries matching \002{0}\002 on the access list of \002{1}\002."), mask, ci->GetName()); else { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << nicks; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), mask); if (deleted == 1) source.Reply(_("Deleted \0021\002 entry from the access list of \002{0}\002."), ci->GetName()); @@ -308,7 +309,7 @@ class CommandCSAccess : public Command { source.Reply(_("\002{0}\002 deleted from the access list of \002{1}\002."), access->Mask(), ci->GetName()); bool override = !u_access.founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->Mask().equals_ci(source.nc->GetDisplay()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->Mask(); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {3}"), access->Mask()); EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, access); delete access; @@ -458,7 +459,7 @@ class CommandCSAccess : public Command source.Reply(_("The access list of \002{0}\002 has been cleared."), ci->GetName()); bool override = !source.IsFounder(ci); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the access list")); } public: @@ -672,7 +673,7 @@ class CommandCSLevels : public Command else { bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << p->name << " to level " << level; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to set {0} to level {1}"), p->name, level); ci->SetLevel(p->name, level); EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, p->name, level); @@ -699,7 +700,7 @@ class CommandCSLevels : public Command if (p != NULL) { bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable " << p->name; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable {0}"), p->name); ci->SetLevel(p->name, ChanServ::ACCESS_INVALID); EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, p->name, ChanServ::ACCESS_INVALID); @@ -754,7 +755,7 @@ class CommandCSLevels : public Command void DoReset(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to reset all levels"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to reset all levels")); ci->ClearLevels(); EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, "ALL", 0); diff --git a/modules/chanserv/akick.cpp b/modules/chanserv/akick.cpp index 9338a4dd7..35bca6818 100644 --- a/modules/chanserv/akick.cpp +++ b/modules/chanserv/akick.cpp @@ -302,7 +302,10 @@ class CommandCSAKick : public Command else ak = ci->AddAkick(source.GetNick(), mask, reason); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason; + if (reason.empty()) + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0}"), mask); + else + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0} ({1})"), mask, reason); EventManager::Get()->Dispatch(&Event::Akick::OnAkickAdd, source, ci, ak); @@ -337,10 +340,11 @@ class CommandCSAKick : public Command EventManager::Get()->Dispatch(&Event::Akick::OnAkickDel, source, ci, ak); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << (ak->GetAccount() ? ak->GetAccount()->GetDisplay() : ak->GetMask()); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), + ak->GetAccount() ? ak->GetAccount()->GetDisplay() : ak->GetMask()); ++deleted; - delete ak; + ak->Delete(); }, [&]() { @@ -357,29 +361,33 @@ class CommandCSAKick : public Command { NickServ::Nick *na = NickServ::FindNick(mask); NickServ::Account *nc = na ? na->GetAccount() : nullptr; + AutoKick *match = nullptr; - unsigned int i, end; - for (i = 0, end = ci->GetAkickCount(); i < end; ++i) + for (unsigned int i = 0; i < ci->GetAkickCount(); ++i) { AutoKick *ak = ci->GetAkick(i); if (ak->GetAccount() ? ak->GetAccount() == nc : mask.equals_ci(ak->GetMask())) + { + match = ak; break; + } } - if (i == ci->GetAkickCount()) + if (match == nullptr) { source.Reply(_("\002{0}\002 was not found on the auto kick list of \002{1}\002."), mask, ci->GetName()); return; } - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), + match->GetAccount() ? match->GetAccount()->GetDisplay() : match->GetMask()); - EventManager::Get()->Dispatch(&Event::Akick::OnAkickDel, source, ci, ci->GetAkick(i)); + EventManager::Get()->Dispatch(&Event::Akick::OnAkickDel, source, ci, match); - delete ci->GetAkick(i); + source.Reply(_("\002{0}\002 deleted from the auto kick list of \002{1}\002."), match->GetAccount() ? match->GetAccount()->GetDisplay() : match->GetMask(), ci->GetName()); - source.Reply(_("\002{0}\002 deleted from the auto kick list of \002{1}\002."), mask, ci->GetName()); + match->Delete(); } } @@ -523,7 +531,8 @@ class CommandCSAKick : public Command } bool override = !source.AccessFor(ci).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ENFORCE, affects " << count << " users"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, + _("{source} used {command} on {channel} to enforce the akick list, affects {0} users"), count); source.Reply(_("Autokick enforce for \002{0}\002 complete; \002{1}\002 users were affected."), ci->GetName(), count); } @@ -531,7 +540,7 @@ class CommandCSAKick : public Command void DoClear(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the akick list"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the akick list")); ci->ClearAkick(); source.Reply(_("The autokick list of \002{0}\002 has been cleared."), ci->GetName()); @@ -712,7 +721,8 @@ class CSAKick : public Module if (kick) { - Log(LOG_DEBUG_2) << u->nick << " matched akick " << (ak->GetAccount() ? ak->GetAccount()->GetDisplay() : ak->GetMask()); + logger.Debug2("{0} matched akick {1}", u->nick, ak->GetAccount() ? ak->GetAccount()->GetDisplay() : ak->GetMask()); + ak->SetLastUsed(Anope::CurTime); if (!ak->GetAccount() && ak->GetMask().find('#') == Anope::string::npos) mask = ak->GetMask(); diff --git a/modules/chanserv/ban.cpp b/modules/chanserv/ban.cpp index 2b73df8fb..d79afe071 100644 --- a/modules/chanserv/ban.cpp +++ b/modules/chanserv/ban.cpp @@ -152,7 +152,7 @@ class CommandCSBan : public Command Anope::string mask = ci->GetIdealBan(u2); bool override = !u_access.HasPriv("BAN") || (u != u2 && ci->IsPeace() && u2_access >= u_access); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << mask; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), mask); if (!c->HasMode(mode, mask)) { @@ -188,7 +188,7 @@ class CommandCSBan : public Command Anope::string mask = IRCD->NormalizeMask(target); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << mask; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), mask); if (!c->HasMode(mode, mask)) { diff --git a/modules/chanserv/clone.cpp b/modules/chanserv/clone.cpp index 8d0c1ce3a..343e6c5b2 100644 --- a/modules/chanserv/clone.cpp +++ b/modules/chanserv/clone.cpp @@ -209,7 +209,8 @@ public: return; } - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->GetName(); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clone {0} to {1}"), + what.empty() ? "everything from it" : what, target_ci->GetName()); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/chanserv/drop.cpp b/modules/chanserv/drop.cpp index 77ab7e55e..122ac96b8 100644 --- a/modules/chanserv/drop.cpp +++ b/modules/chanserv/drop.cpp @@ -63,7 +63,8 @@ class CommandCSDrop : public Command return; bool override = (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "none") << ")"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} (founder was: {0})"), + ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "none"); Reference<Channel> c = ci->c; ci->Delete(); diff --git a/modules/chanserv/enforce.cpp b/modules/chanserv/enforce.cpp index e1d084075..8d41c7af3 100644 --- a/modules/chanserv/enforce.cpp +++ b/modules/chanserv/enforce.cpp @@ -25,7 +25,7 @@ class CommandCSEnforce : public Command void DoSecureOps(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce secureops"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce secureops")); /* Dirty hack to allow Channel::SetCorrectModes to work ok. * We pretend like SECUREOPS is on so it doesn't ignore that @@ -51,7 +51,7 @@ class CommandCSEnforce : public Command void DoRestricted(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce restricted"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce restricted")); std::vector<User *> users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -82,7 +82,7 @@ class CommandCSEnforce : public Command void DoRegOnly(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce registered only"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce registered only")); std::vector<User *> users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -114,7 +114,7 @@ class CommandCSEnforce : public Command void DoSSLOnly(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce SSL only"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce SSL only")); std::vector<User *> users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -146,7 +146,7 @@ class CommandCSEnforce : public Command void DoBans(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce bans"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce bans")); std::vector<User *> users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -175,7 +175,7 @@ class CommandCSEnforce : public Command void DoLimit(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce limit"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce limit")); Anope::string l_str; if (!ci->c->GetParam("LIMIT", l_str)) diff --git a/modules/chanserv/entrymsg.cpp b/modules/chanserv/entrymsg.cpp index c739ba46a..b2edbc56f 100644 --- a/modules/chanserv/entrymsg.cpp +++ b/modules/chanserv/entrymsg.cpp @@ -151,7 +151,9 @@ class CommandEntryMessage : public Command msg->SetChannel(ci); msg->SetCreator(source.GetNick()); msg->SetMessage(message); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to add a message"; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to add a message")); + source.Reply(_("Entry message added to \002{0}\002"), ci->GetName()); } @@ -177,7 +179,9 @@ class CommandEntryMessage : public Command if (i > 0 && i <= messages.size()) { messages[i - 1]->Delete(); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove a message"; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to remove a message")); + source.Reply(_("Entry message \002{0}\002 for \002{1]\002 deleted."), i, ci->GetName()); } else @@ -192,9 +196,10 @@ class CommandEntryMessage : public Command void DoClear(CommandSource &source, ChanServ::Channel *ci) { for (EntryMsg *e : ci->GetRefs<EntryMsg *>()) - delete e; + e->Delete(); + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to remove all messages")); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove all messages"; source.Reply(_("Entry messages for \002{0}\002 have been cleared."), ci->GetName()); } diff --git a/modules/chanserv/flags.cpp b/modules/chanserv/flags.cpp index 4732aff5b..d87863be0 100644 --- a/modules/chanserv/flags.cpp +++ b/modules/chanserv/flags.cpp @@ -266,9 +266,12 @@ class CommandCSFlags : public Command if (current != NULL) { EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, current); - delete current; - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; - source.Reply(_("\002{0}\002 removed from the access list of \002{1}\002."), mask, ci->GetName()); + + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), current->Mask()); + + source.Reply(_("\002{0}\002 removed from the access list of \002{1}\002."), current->Mask(), ci->GetName()); + + current->Delete(); } else { @@ -290,11 +293,12 @@ class CommandCSFlags : public Command access->SetFlags(Anope::string(current_flags.begin(), current_flags.end())); if (current != NULL) - delete current; + current->Delete(); EventManager::Get()->Dispatch(&Event::AccessAdd::OnAccessAdd, ci, source, access); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->AccessSerialize(); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to modify flags of {0} to {1}"), access->Mask(), access->AccessSerialize()); + if (p != NULL) { if (add) @@ -303,7 +307,9 @@ class CommandCSFlags : public Command source.Reply(_("Privilege \002{0}\002 removed from \002{1}\002 on \002{2}\002, new flags are +\002{3}\002"), p->name, access->Mask(), ci->GetName(), access->AccessSerialize()); } else + { source.Reply(_("Flags for \002{0}\002 on \002{1}\002 set to +\002{2}\002"), access->Mask(), ci->GetName(), access->AccessSerialize()); + } } void DoList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) @@ -383,7 +389,7 @@ class CommandCSFlags : public Command source.Reply(_("The access list of \002{0}\002 has been cleared."), ci->GetName()); bool override = !source.IsFounder(ci); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the access list")); } public: diff --git a/modules/chanserv/getkey.cpp b/modules/chanserv/getkey.cpp index cbcc66720..2e6835672 100644 --- a/modules/chanserv/getkey.cpp +++ b/modules/chanserv/getkey.cpp @@ -53,7 +53,7 @@ class CommandCSGetKey : public Command } bool override = !source.AccessFor(ci).HasPriv("GETKEY"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); source.Reply(_("Key for channel \002{0}\002 is \002{1}\002."), ci->GetName(), key); } diff --git a/modules/chanserv/invite.cpp b/modules/chanserv/invite.cpp index 9c21bc704..ae6cee04d 100644 --- a/modules/chanserv/invite.cpp +++ b/modules/chanserv/invite.cpp @@ -83,12 +83,12 @@ class CommandCSInvite : public Command { source.Reply(_("\002{0}\002 has been invited to \002{1}\002."), u2->nick, c->name); u2->SendMessage(ci->WhoSends(), _("You have been invited to \002{0}\002 by \002{1}\002."), c->name, source.GetNick()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << u2->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to invite {0}"), u2->nick); } else { u2->SendMessage(ci->WhoSends(), _("You have been invited to \002{0}\002."), c->name); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); } } diff --git a/modules/chanserv/kick.cpp b/modules/chanserv/kick.cpp index 505f74893..fad7b9158 100644 --- a/modules/chanserv/kick.cpp +++ b/modules/chanserv/kick.cpp @@ -79,7 +79,7 @@ class CommandCSKick : public Command else { bool override = !u_access.HasPriv("KICK") || (u != u2 && ci->IsPeace() && u2_access >= u_access); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << u2->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), u2->nick); if (ci->IsSignKick() || (ci->IsSignKickLevel() && !u_access.HasPriv("SIGNKICK"))) { @@ -96,7 +96,7 @@ class CommandCSKick : public Command { Anope::string mask = IRCD->NormalizeMask(target); - Log(LOG_COMMAND, source, this, ci) << "for " << mask; + logger.Command(LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), mask); int matched = 0, kicked = 0; for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end;) diff --git a/modules/chanserv/list.cpp b/modules/chanserv/list.cpp index a60ae786c..cd855a0b3 100644 --- a/modules/chanserv/list.cpp +++ b/modules/chanserv/list.cpp @@ -215,13 +215,15 @@ class CommandCSSetPrivate : public Command if (params[1].equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable private"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable private")); + ci->SetPrivate(true); source.Reply(_("Private option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (params[1].equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable private"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable private")); + ci->SetPrivate(false); source.Reply(_("Private option for \002{0}\002 is now \002off\002."), ci->GetName()); } diff --git a/modules/chanserv/log.cpp b/modules/chanserv/log.cpp index 4cbc66c7e..52724a57b 100644 --- a/modules/chanserv/log.cpp +++ b/modules/chanserv/log.cpp @@ -285,15 +285,24 @@ public: { if (log->GetExtra() == extra) { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to remove logging for " << command << " with method " << method << (extra == "" ? "" : " ") << extra; - source.Reply(_("Logging for command \002{0}\002 on \002{1}\002 with log method \002{2}{3}{4}\002 has been removed."), !log->GetCommandName().empty() ? log->GetCommandName() : log->GetServiceName(), !log->GetCommandService().empty() ? log->GetCommandService() : "any service", method, extra.empty() ? "" : " ", extra); - delete log; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to remove logging for {0} with method {1}"), + command, method + (extra.empty() ? "" : (" " + extra))); + + source.Reply(_("Logging for command \002{0}\002 on \002{1}\002 with log method \002{2}{3}{4}\002 has been removed."), + !log->GetCommandName().empty() ? log->GetCommandName() : log->GetServiceName(), + !log->GetCommandService().empty() ? log->GetCommandService() : "any service", method, extra.empty() ? "" : " ", extra); + log->Delete(); } else { log->SetExtra(extra); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to change logging for " << command << " to method " << method << (extra == "" ? "" : " ") << extra; - source.Reply(_("Logging changed for command \002{0}\002 on \002{1}\002, now using log method \002{2}{3}{4]\002."), !log->GetCommandName().empty() ? log->GetCommandName() : log->GetServiceName(), !log->GetCommandService().empty() ? log->GetCommandService() : "any service", method, extra.empty() ? "" : " ", extra); + + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to change logging for {0} to method {1}"), + command, method + (extra.empty() ? "" : (" " + extra))); + + source.Reply(_("Logging changed for command \002{0}\002 on \002{1}\002, now using log method \002{2}{3}{4]\002."), + !log->GetCommandName().empty() ? log->GetCommandName() : log->GetServiceName(), + !log->GetCommandService().empty() ? log->GetCommandService() : "any service", method, extra.empty() ? "" : " ", extra); } return; } @@ -310,9 +319,11 @@ public: log->SetCreated(Anope::CurTime); log->SetCreator(source.GetNick()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to log " << command << " with method " << method << (extra == "" ? "" : " ") << extra; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, + _("{source} used {command} on {channel} to log {0} to method {1}"), command, method + (extra.empty() ? "" : (" " + extra))); - source.Reply(_("Logging is now active for command \002{0}\002 on \002{1}\002, using log method \002{2}{3}{4}\002."), !command_name.empty() ? command_name : service_name, bi ? bi->nick : "any service", method, extra.empty() ? "" : " ", extra); + source.Reply(_("Logging is now active for command \002{0}\002 on \002{1}\002, using log method \002{2}{3}{4}\002."), + !command_name.empty() ? command_name : service_name, bi ? bi->nick : "any service", method, extra.empty() ? "" : " ", extra); } else { @@ -423,9 +434,11 @@ class CSLog : public Module } } - void OnLog(::Log *l) override + void OnLog(Logger *l) override { - if (l->type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced()) +#warning "fix log" +#if 0 + if (l->type != LogType::COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced()) return; std::vector<LogSetting *> ls = l->ci->GetRefs<LogSetting *>(); @@ -463,6 +476,7 @@ class CSLog : public Module else if (log->GetMethod().equals_ci("NOTICE") && l->ci->c) IRCD->SendNotice(l->ci->WhoSends(), log->GetExtra() + l->ci->c->name, buffer); } +#endif } }; diff --git a/modules/chanserv/main/channel.cpp b/modules/chanserv/main/channel.cpp index a35c80901..d10abbc0d 100644 --- a/modules/chanserv/main/channel.cpp +++ b/modules/chanserv/main/channel.cpp @@ -30,7 +30,7 @@ void ChannelImpl::Delete() { EventManager::Get()->Dispatch(&Event::DelChan::OnDelChan, this); - Log(LOG_DEBUG) << "Deleting channel " << this->GetName(); + Anope::Logger.Debug("Deleting channel {0}", this->GetName()); if (this->c) { @@ -361,7 +361,7 @@ ChanServ::AccessGroup ChannelImpl::AccessFor(const User *u, bool updateLastUsed) return group; NickServ::Account *nc = u->Account(); - if (nc == NULL && !nc->IsSecure() && u->IsRecognized()) + if (nc == NULL && !this->IsSecure() && u->IsRecognized()) { NickServ::Nick *na = NickServ::FindNick(u->nick); if (na != NULL) @@ -480,7 +480,7 @@ int16_t ChannelImpl::GetLevel(const Anope::string &priv) ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(priv) : nullptr; if (!p) { - Log(LOG_DEBUG) << "Unknown privilege " + priv; + Anope::Logger.Debug("Unknown privilege {0}", priv); return ChanServ::ACCESS_INVALID; } @@ -499,7 +499,7 @@ void ChannelImpl::SetLevel(const Anope::string &priv, int16_t level) ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(priv) : nullptr; if (!p) { - Log(LOG_DEBUG) << "Unknown privilege " + priv; + Anope::Logger.Debug("Unknown privilege {0}", priv); return; } @@ -538,7 +538,7 @@ Anope::string ChannelImpl::GetIdealBan(User *u) else return "*!" + u->GetVIdent() + "@" + u->GetDisplayedHost(); case 3: - return "*!" + u->Mask(); + return "*!" + u->WildMask(); case 2: default: return "*!*@" + u->GetDisplayedHost(); diff --git a/modules/chanserv/main/chanserv.cpp b/modules/chanserv/main/chanserv.cpp index 492f64459..62d1e81ba 100644 --- a/modules/chanserv/main/chanserv.cpp +++ b/modules/chanserv/main/chanserv.cpp @@ -309,7 +309,9 @@ class ChanServCore : public Module if (newowner) { - ::Log(LOG_NORMAL, "chanserv/drop", ChanServ) << "Transferring foundership of " << ci->GetName() << " from deleted account " << nc->GetDisplay() << " to " << newowner->GetDisplay(); + ChanServ->logger.Category("chanserv/drop").Log(_("Transferring foundership of {0} from deleted account {1} to {2}"), + ci->GetName(), nc->GetDisplay(), newowner->GetDisplay()); + ci->SetFounder(newowner); // Can't be both founder and successor @@ -318,7 +320,8 @@ class ChanServCore : public Module } else { - ::Log(LOG_NORMAL, "chanserv/drop", ChanServ) << "Deleting channel " << ci->GetName() << " owned by deleted account " << nc->GetDisplay(); + ChanServ->logger.Category("chanserv/drop").Log(_("Deleting channel {0} owned by deleted account {1}"), + ci->GetName(), nc->GetDisplay()); ci->Delete(); continue; @@ -408,10 +411,13 @@ class ChanServCore : public Module } } - void OnLog(::Log *l) override + void OnLog(Logger *l) override { - if (l->type == LOG_CHANNEL) +#warning "" +#if 0 + if (l->type == LogType::CHANNEL) l->bi = ChanServ; +#endif } void OnExpireTick() override @@ -442,7 +448,9 @@ class ChanServCore : public Module if (expire) { - ::Log(LOG_NORMAL, "chanserv/expire", ChanServ) << "Expiring channel " << ci->GetName() << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "(none)") << ")"; + ChanServ->logger.Category("chanserv/expire").Log(_("Expiring channel {0} (founder: {1})"), + ci->GetName(), ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "(none)"); + EventManager::Get()->Dispatch(&ChanServ::Event::ChanExpire::OnChanExpire, ci); ci->Delete(); } @@ -511,7 +519,7 @@ class ChanServCore : public Module { if (always_lower && c->ci && c->creation_time > c->ci->GetTimeRegistered()) { - ::Log(LOG_DEBUG) << "Changing TS of " << c->name << " from " << c->creation_time << " to " << c->ci->GetTimeRegistered(); + logger.Debug("Changing TS of {0} from {1} to {2}", c->name, c->creation_time, c->ci->GetTimeRegistered()); c->creation_time = c->ci->GetTimeRegistered(); IRCD->Send<messages::MessageChannel>(c); c->Reset(); diff --git a/modules/chanserv/mode.cpp b/modules/chanserv/mode.cpp index 5a22b4be8..e76469823 100644 --- a/modules/chanserv/mode.cpp +++ b/modules/chanserv/mode.cpp @@ -374,7 +374,8 @@ class CommandCSMode : public Command if (!reply.empty()) { source.Reply(_("\002{0}\002 locked on \002{1}\002."), reply, ci->GetName()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to lock " << reply; + + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to lock {0}"), reply); } else if (needreply) { @@ -430,7 +431,9 @@ class CommandCSMode : public Command if (!mode_param.empty()) mode_param = " " + mode_param; source.Reply(_("\002{0}{1}{2}\002 has been unlocked from \002{3}\002."), adding == 1 ? '+' : '-', cm->mchar, mode_param, ci->GetName()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->mchar << mode_param; + + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to unlock {0}"), + (adding ? '+' : '-') + cm->mchar + mode_param); } else { @@ -493,7 +496,8 @@ class CommandCSMode : public Command Anope::string modes = params[2], param; bool override = !source.AccessFor(ci).HasPriv("MODE") && source.HasPriv("chanserv/administration"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << params[2] << (params.size() > 3 ? " " + params[3] : ""); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to set {3}"), + params[2] + (params.size() > 3 ? " " + params[3] : "")); int adding = -1; for (size_t i = 0; i < modes.length(); ++i) @@ -850,7 +854,7 @@ class CommandCSModes : public Command else ci->c->RemoveMode(NULL, m.second, targ->GetUID()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "on " << targ->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} on {3}"), targ->nick); } const Anope::string GetDesc(CommandSource &source) const override diff --git a/modules/chanserv/register.cpp b/modules/chanserv/register.cpp index 1e2a6a2bd..0e7bff7a0 100644 --- a/modules/chanserv/register.cpp +++ b/modules/chanserv/register.cpp @@ -121,7 +121,8 @@ class CommandCSRegister : public Command ci->SetLastTopicSetter(source.service->nick); } - Log(LOG_COMMAND, source, this, ci); + logger.Command(LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); + source.Reply(_("Channel \002{0}\002 registered under your account: \002{1}\002"), chan, nc->GetDisplay()); /* Implement new mode lock */ diff --git a/modules/chanserv/seen.cpp b/modules/chanserv/seen.cpp index 113691343..2028634f4 100644 --- a/modules/chanserv/seen.cpp +++ b/modules/chanserv/seen.cpp @@ -165,12 +165,12 @@ class CommandOSSeen : public Command ++it; if (time < buf->second->last) { - Log(LOG_DEBUG) << buf->first << " was last seen " << Anope::strftime(buf->second->last) << ", deleting entry"; + Log(LogType::DEBUG) << buf->first << " was last seen " << Anope::strftime(buf->second->last) << ", deleting entry"; delete buf->second; counter++; } } - Log(LOG_ADMIN, source, this) << "CLEAR and removed " << counter << " nicks that were added after " << Anope::strftime(time, NULL, true); + Log(LogType::ADMIN, source, this) << "CLEAR and removed " << counter << " nicks that were added after " << Anope::strftime(time, NULL, true); source.Reply(_("Database cleared, removed %lu nicks that were added after %s."), counter, Anope::strftime(time, source.nc, true).c_str()); } else @@ -423,11 +423,11 @@ class CSSeen : public Module if ((Anope::CurTime - cur->second->last) > purgetime) { - Log(LOG_DEBUG) << cur->first << " was last seen " << Anope::strftime(cur->second->last) << ", purging entries"; + Log(LogType::DEBUG) << cur->first << " was last seen " << Anope::strftime(cur->second->last) << ", purging entries"; delete cur->second; } } - Log(LOG_DEBUG) << "cs_seen: Purged database, checked " << previous_size << " nicks and removed " << (previous_size - database.size()) << " old entries."; + Log(LogType::DEBUG) << "cs_seen: Purged database, checked " << previous_size << " nicks and removed " << (previous_size - database.size()) << " old entries."; } void OnUserConnect(User *u, bool &exempt) override diff --git a/modules/chanserv/set.cpp b/modules/chanserv/set.cpp index 833817cde..7b6775c2f 100644 --- a/modules/chanserv/set.cpp +++ b/modules/chanserv/set.cpp @@ -26,7 +26,7 @@ class CommandCSSet : public Command { ServiceReference<ModeLocks> mlocks; - + public: CommandCSSet(Module *creator) : Command(creator, "chanserv/set", 2, 3) { @@ -117,13 +117,15 @@ class CommandCSSetAutoOp : public Command if (params[1].equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable autoop"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable autoop")); + ci->SetNoAutoop(false); source.Reply(_("Services will now automatically give modes to users in \002{0}\002."), ci->GetName()); } else if (params[1].equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable autoop"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable autoop")); + ci->SetNoAutoop(true); source.Reply(_("Services will no longer automatically give modes to users in \002{0}\002."), ci->GetName()); } @@ -182,7 +184,9 @@ class CommandCSSetBanType : public Command int16_t new_type = convertTo<int16_t>(params[1]); if (new_type < 0 || new_type > 3) throw ConvertException("Invalid range"); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change the ban type to " << new_type; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the ban type to {0}"), new_type); + ci->SetBanType(new_type); source.Reply(_("Ban type for channel \002{0}\002 is now \002#{1}\002."), ci->GetName(), new_type); } @@ -247,12 +251,14 @@ class CommandCSSetDescription : public Command ci->SetDesc(param); if (!param.empty()) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change the description to " << ci->GetDesc(); + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the description to {0}"), ci->GetDesc()); + source.Reply(_("Description of \002{0}\002 changed to \002{1}\002."), ci->GetName(), ci->GetDesc()); } else { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to unset the description"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to unset the description")); + source.Reply(_("Description of \002{0}\002 unset."), ci->GetName()); } } @@ -317,7 +323,8 @@ class CommandCSSetFounder : public Command return; } - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change the founder from " << (ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "(none)") << " to " << nc->GetDisplay(); + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the founder from {0} to {1}"), + ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "(none)", nc->GetDisplay()); ci->SetFounder(nc); @@ -373,7 +380,8 @@ class CommandCSSetKeepModes : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable keep modes"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable keep modes")); + ci->SetKeepModes(true); source.Reply(_("Keep modes for \002{0}\002 is now \002on\002."), ci->GetName()); if (ci->c) @@ -387,7 +395,8 @@ class CommandCSSetKeepModes : public Command } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable keep modes"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable keep modes")); + ci->SetKeepModes(false); source.Reply(_("Keep modes for \002{0}\002 is now \002off\002."), ci->GetName()); for (ChanServ::Mode *m : ci->GetRefs<ChanServ::Mode *>()) @@ -446,13 +455,15 @@ class CommandCSSetPeace : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable peace"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable peace")); + ci->SetPeace(true); source.Reply(_("Peace option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable peace"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable peace")); + ci->SetPeace(false); source.Reply(_("Peace option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -481,7 +492,7 @@ inline static Anope::string BotModes() class CommandCSSetPersist : public Command { ServiceReference<ModeLocks> mlocks; - + public: CommandCSSetPersist(Module *creator, const Anope::string &cname = "chanserv/set/persist") : Command(creator, cname, 2, 2) { @@ -570,7 +581,8 @@ class CommandCSSetPersist : public Command } } - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable persist"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable persist")); + source.Reply(_("Channel \002{0}\002 is now persistent."), ci->GetName()); } else if (params[1].equals_ci("OFF")) @@ -607,7 +619,8 @@ class CommandCSSetPersist : public Command } } - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable persist"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable persist")); + source.Reply(_("Channel \002{0}\002 is no longer persistent."), ci->GetName()); } else @@ -664,13 +677,15 @@ class CommandCSSetRestricted : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable restricted"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable restricted")); + ci->SetRestricted(true); source.Reply(_("Restricted access option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable restricted"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disabled restricted")); + ci->SetRestricted(false); source.Reply(_("Restricted access option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -727,13 +742,15 @@ class CommandCSSetSecure : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable secure"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable secure")); + ci->SetSecure(true); source.Reply(_("Secure option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable secure"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable secure")); + ci->SetSecure(false); source.Reply(_("Secure option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -792,13 +809,15 @@ class CommandCSSetSecureFounder : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable secure founder"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable secure founder")); + ci->SetSecureFounder(true); source.Reply(_("Secure founder option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable secure founder"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable secure founder")); + ci->SetSecureFounder(false); source.Reply(_("Secure founder option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -860,13 +879,15 @@ class CommandCSSetSecureOps : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable secure ops"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable secure ops")); + ci->SetSecureOps(true); source.Reply(_("Secure ops option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable secure ops"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable secure ops")); + ci->SetSecureOps(false); source.Reply(_("Secure ops option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -927,21 +948,24 @@ class CommandCSSetSignKick : public Command ci->SetSignKick(true); ci->SetSignKickLevel(false); source.Reply(_("Signed kick option for \002{0}\002 is now \002on\002."), ci->GetName()); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable sign kick"; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable sign kick")); } else if (param.equals_ci("LEVEL")) { ci->SetSignKick(false); ci->SetSignKickLevel(true); source.Reply(_("Signed kick option for \002{0}\002 is now \002on\002, but depends of the privileges of the user that is using the command."), ci->GetName()); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable sign kick level"; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable sign kick level")); } else if (param.equals_ci("OFF")) { ci->SetSignKick(false); ci->SetSignKickLevel(false); source.Reply(_("Signed kick option for \002{0}\002 is now \002off\002."), ci->GetName()); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable sign kick"; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable sign kick")); } else { @@ -1018,7 +1042,8 @@ class CommandCSSetSuccessor : public Command nc = na->GetAccount(); } - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change the successor from " << (ci->GetSuccessor() ? ci->GetSuccessor()->GetDisplay() : "(none)") << " to " << (nc ? nc->GetDisplay() : "(none)"); + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the successor from {0} to {1}"), + ci->GetSuccessor() ? ci->GetSuccessor()->GetDisplay() : "(none)", nc ? nc->GetDisplay() : "(none)"); ci->SetSuccessor(nc); @@ -1072,13 +1097,15 @@ class CommandCSSetNoexpire : public Command if (param.equals_ci("ON")) { - Log(LOG_ADMIN, source, this, ci) << "to enable noexpire"; + logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} to enable noexpire")); + ci->SetNoExpire(true); source.Reply(_("Channel \002{0} will not\002 expire."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(LOG_ADMIN, source, this, ci) << "to disable noexpire"; + logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} to disable noexpire")); + ci->SetNoExpire(false); source.Reply(_("Channel \002{0} will\002 expire."), ci->GetName()); } @@ -1240,7 +1267,7 @@ class CSSet : public Module { if (persist_lower_ts && c->ci && c->ci->IsPersist() && c->creation_time > c->ci->GetTimeRegistered()) { - Log(LOG_DEBUG) << "Changing TS of " << c->name << " from " << c->creation_time << " to " << c->ci->GetTimeRegistered(); + logger.Debug("Changing TS of {0} from {1} to {2}", c->name, c->creation_time, c->ci->GetTimeRegistered()); c->creation_time = c->ci->GetTimeRegistered(); IRCD->Send<messages::MessageChannel>(c); c->Reset(); diff --git a/modules/chanserv/set_misc.cpp b/modules/chanserv/set_misc.cpp index 7bf55dfc6..76f4c7017 100644 --- a/modules/chanserv/set_misc.cpp +++ b/modules/chanserv/set_misc.cpp @@ -151,12 +151,16 @@ class CommandCSSetMisc : public Command data->SetName(scommand); data->SetData(param); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change it to " << param; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, + _("{source} used {command} on {channel} to change it to {0}"), + param); + source.Reply(_("\002{0}\002 for \002{1}\002 set to \002{2}\002."), scommand, ci->GetName(), param); } else { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to unset it"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to unset it")); + source.Reply(_("\002{0}\002 for \002{1}\002 unset."), scommand, ci->GetName()); } } diff --git a/modules/chanserv/suspend.cpp b/modules/chanserv/suspend.cpp index 7895aaa02..c686ffdb7 100644 --- a/modules/chanserv/suspend.cpp +++ b/modules/chanserv/suspend.cpp @@ -189,7 +189,9 @@ class CommandCSSuspend : public Command ci->c->Kick(NULL, users[i], !reason.empty() ? reason : Language::Translate(users[i], _("This channel has been suspended."))); } - Log(LOG_ADMIN, source, this, ci) << "(" << (!reason.empty() ? reason : "No reason") << "), expires on " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); + logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} ({0}), expires on {1}"), + !reason.empty() ? reason : "No reason", expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); + source.Reply(_("Channel \002{0}\002 is now suspended."), ci->GetName()); EventManager::Get()->Dispatch(&Event::ChanSuspend::OnChanSuspend, ci); @@ -234,11 +236,12 @@ class CommandCSUnSuspend : public Command return; } - Log(LOG_ADMIN, source, this, ci) << "which was suspended by " << si->GetBy() << " for: " << (!si->GetReason().empty() ? si->GetReason() : "No reason"); + logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} which was suspended by {0} for: {1}"), + si->GetBy(), !si->GetReason().empty() ? si->GetReason() : "No reason"); si->Delete(); - source.Reply(_("Channel \002%s\002 is now released."), ci->GetName().c_str()); + source.Reply(_("Channel \002{0}\002 is now released."), ci->GetName()); EventManager::Get()->Dispatch(&Event::ChanUnsuspend::OnChanUnsuspend, ci); } @@ -320,7 +323,7 @@ class CSSuspend : public Module ci->SetLastUsed(Anope::CurTime); si->Delete(); - Log(this) << "Expiring suspend for " << ci->GetName(); + logger.Channel(ci).Log(_("Expiring suspend for {0}"), ci->GetName()); } } diff --git a/modules/chanserv/sync.cpp b/modules/chanserv/sync.cpp index 9f9ba4ff7..c532d4fad 100644 --- a/modules/chanserv/sync.cpp +++ b/modules/chanserv/sync.cpp @@ -52,7 +52,7 @@ class CommandCSSync : public Command } bool override = !source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/administration"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) ci->c->SetCorrectModes(it->second->user, true); diff --git a/modules/chanserv/topic.cpp b/modules/chanserv/topic.cpp index db4d25dbd..648c322fb 100644 --- a/modules/chanserv/topic.cpp +++ b/modules/chanserv/topic.cpp @@ -62,13 +62,15 @@ class CommandCSSetKeepTopic : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable keeptopic"; + logger.Command(!source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to enable keeptopic")); + ci->SetKeepTopic(true); source.Reply(_("Topic retention option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable keeptopic"; + logger.Command(!source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to disable keeptopic")); + ci->SetKeepTopic(false); source.Reply(_("Topic retention option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -132,7 +134,10 @@ class CommandCSTopic : public Command ci->SetTopicLock(true); bool override = !source.AccessFor(ci).HasPriv("TOPIC"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << (!topic.empty() ? "to change the topic to: " : "to unset the topic") << (!topic.empty() ? topic : ""); + if (!topic.empty()) + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to change the topic to: {0}"), topic); + else + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to unset the topic")); } void Append(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) diff --git a/modules/chanserv/unban.cpp b/modules/chanserv/unban.cpp index 035819ff2..ac7c08fdf 100644 --- a/modules/chanserv/unban.cpp +++ b/modules/chanserv/unban.cpp @@ -42,20 +42,20 @@ class CommandCSUnban : public Command if (!source.GetUser()) return; - unsigned count = 0; + unsigned int count = 0; for (ChanServ::Channel *ci : source.GetAccount()->GetRefs<ChanServ::Channel *>()) { if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN")) continue; - for (unsigned j = 0; j < modes.size(); ++j) + for (unsigned int j = 0; j < modes.size(); ++j) if (ci->c->Unban(source.GetUser(), modes[j]->name, true)) ++count; } - Log(LOG_COMMAND, source, this, NULL) << "on all channels"; - source.Reply(_("You have been unbanned from %d channels."), count); + logger.Command(LogType::COMMAND, source, _("{source} used {command} on all channels")); + source.Reply(_("You have been unbanned from \002{0}\002 channels."), count); return; } @@ -92,7 +92,7 @@ class CommandCSUnban : public Command } bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unban " << u2->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to unban {0}"), u2->nick); for (unsigned i = 0; i < modes.size(); ++i) ci->c->Unban(u2, modes[i]->name, source.GetUser() == u2); diff --git a/modules/chanserv/updown.cpp b/modules/chanserv/updown.cpp index 38ed65776..d3ceb617a 100644 --- a/modules/chanserv/updown.cpp +++ b/modules/chanserv/updown.cpp @@ -68,7 +68,8 @@ class CommandCSUp : public Command Channel *c = it->second->chan; SetModes(source.GetUser(), c); } - Log(LOG_COMMAND, source, this, NULL) << "on all channels to update their status modes"; + + logger.Command(LogType::COMMAND, source, _("{source} used {command} on all channels to update their status modes"), source.GetSource(), source.GetCommand()); return; } @@ -131,7 +132,8 @@ class CommandCSUp : public Command } } - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to update the status modes of " << u->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to update the status modes of {0}"), u->nick); + SetModes(u, c); } @@ -172,7 +174,7 @@ class CommandCSDown : public Command Channel *c = it->second->chan; RemoveAll(source.GetUser(), c); } - Log(LOG_COMMAND, source, this, NULL) << "on all channels to remove their status modes"; + logger.Command(LogType::COMMAND, source, _("{source} used {command} on all channels to remove their status modes"), source.GetSource(), source.GetCommand()); return; } @@ -236,7 +238,8 @@ class CommandCSDown : public Command } } - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to remove the status modes from " << u->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to remove the status modes from {0}"), u->nick); + RemoveAll(u, c); } diff --git a/modules/chanserv/xop.cpp b/modules/chanserv/xop.cpp index de5ca0c0b..b95580a2b 100644 --- a/modules/chanserv/xop.cpp +++ b/modules/chanserv/xop.cpp @@ -134,7 +134,7 @@ class CommandCSXOP : public Command if (Anope::ReadOnly) { - source.Reply(_("Sorry, channel %s list modification is temporarily disabled."), source.command.c_str()); + source.Reply(_("Sorry, channel {0} list modification is temporarily disabled."), source.command); return; } @@ -244,10 +244,10 @@ class CommandCSXOP : public Command acc->SetLastSeen(0); acc->SetCreated(Anope::CurTime); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0}"), mask); EventManager::Get()->Dispatch(&Event::AccessAdd::OnAccessAdd, ci, source, acc); - source.Reply(_("\002%s\002 added to %s %s list."), acc->Mask(), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("\002{0}\002 added to {1} {2} list."), acc->Mask(), ci->GetName(), source.command); } void DoDel(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) @@ -263,13 +263,13 @@ class CommandCSXOP : public Command if (Anope::ReadOnly) { - source.Reply(_("Sorry, channel %s list modification is temporarily disabled."), source.command.c_str()); + source.Reply(_("Sorry, channel {0} list modification is temporarily disabled."), source.command); return; } if (!ci->GetAccessCount()) { - source.Reply(_("%s %s list is empty."), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("{0} {1} list is empty."), ci->GetName(), source.command); return; } @@ -327,20 +327,20 @@ class CommandCSXOP : public Command nicks = caccess->Mask(); EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, caccess); - delete caccess; + caccess->Delete(); }, [&]() { if (!deleted) - source.Reply(_("No matching entries on %s %s list."), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("No matching entries on {0} {1} list."), ci->GetName(), source.command); else { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << nicks; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), nicks); if (deleted == 1) - source.Reply(_("Deleted one entry from %s %s list."), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("Deleted one entry from {0} {1} list."), ci->GetName(), source.command); else - source.Reply(_("Deleted %d entries from %s %s list."), deleted, ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("Deleted {0} entries from {1} {2} list."), deleted, ci->GetName(), source.command); } }); } @@ -355,18 +355,18 @@ class CommandCSXOP : public Command if (a->Mask().equals_ci(mask)) { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << a->Mask(); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), a->GetMask()); - source.Reply(_("\002%s\002 deleted from %s %s list."), a->Mask().c_str(), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("\002{0}\002 deleted from {1} {2} list."), a->Mask(), ci->GetName(), source.command); EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, a); - delete a; + a->Delete(); return; } } - source.Reply(_("\002%s\002 not found on %s %s list."), mask.c_str(), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("\002{0}\002 not found on {1} {2} list."), mask, ci->GetName(), source.command); } } @@ -385,7 +385,7 @@ class CommandCSXOP : public Command if (!ci->GetAccessCount()) { - source.Reply(_("%s %s list is empty."), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("{0} {1} list is empty."), ci->GetName(), source.command); return; } @@ -432,14 +432,14 @@ class CommandCSXOP : public Command if (list.IsEmpty()) { - source.Reply(_("No matching entries on %s access list."), ci->GetName().c_str()); + source.Reply(_("No matching entries on {0} access list."), ci->GetName()); } else { std::vector<Anope::string> replies; list.Process(replies); - source.Reply(_("%s list for %s"), source.command.c_str(), ci->GetName().c_str()); + source.Reply(_("{0} list for {1}"), source.command, ci->GetName()); for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); } @@ -449,13 +449,13 @@ class CommandCSXOP : public Command { if (Anope::ReadOnly) { - source.Reply(_("Sorry, channel %s list modification is temporarily disabled."), source.command.c_str()); + source.Reply(_("Sorry, channel {0} list modification is temporarily disabled."), source.command); return; } if (!ci->GetAccessCount()) { - source.Reply(_("%s %s list is empty."), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("{0} {1} list is empty."), ci->GetName(), source.command); return; } @@ -466,7 +466,7 @@ class CommandCSXOP : public Command } bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the access list")); for (unsigned i = ci->GetAccessCount(); i > 0; --i) { @@ -475,12 +475,12 @@ class CommandCSXOP : public Command if (access->GetSerializableType()->GetName() != "XOPChanAccess" || source.command.upper() != access->AccessSerialize()) continue; - delete access; + access->Delete(); } EventManager::Get()->Dispatch(&Event::AccessClear::OnAccessClear, ci, source); - source.Reply(_("Channel %s %s list has been cleared."), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("Channel {0} {1} list has been cleared."), ci->GetName(), source.command); } public: @@ -494,7 +494,7 @@ class CommandCSXOP : public Command const Anope::string GetDesc(CommandSource &source) const override { - return Anope::printf(Language::Translate(source.GetAccount(), _("Modify the list of %s users")), source.command.upper().c_str()); + return Anope::Format(Language::Translate(source.GetAccount(), _("Modify the list of {0} users")), source.command.upper()); } void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override diff --git a/modules/database/flatfile.cpp b/modules/database/flatfile.cpp index 2f9d0f209..27a51539c 100644 --- a/modules/database/flatfile.cpp +++ b/modules/database/flatfile.cpp @@ -765,7 +765,7 @@ class DBFlatFile : public Module std::fstream fd(db_name.c_str(), std::ios_base::in | std::ios_base::binary); if (!fd.is_open()) { - Log(this) << "Unable to open " << db_name << " for reading!"; + logger.Log("Unable to open {0} for reading!", db_name); return EVENT_STOP; } diff --git a/modules/database/old.cpp b/modules/database/old.cpp index ef93aec66..894b9125b 100644 --- a/modules/database/old.cpp +++ b/modules/database/old.cpp @@ -355,7 +355,7 @@ static dbFILE *open_db_read(const char *service, const char *filename, int versi fp = fopen(f->filename, "rb"); if (!fp) { - Log() << "Can't read " << service << " database " << f->filename; + Anope::Logger.Log("Can't read {0} database {1}", service, f->filename); delete f; return NULL; } @@ -363,13 +363,13 @@ static dbFILE *open_db_read(const char *service, const char *filename, int versi myversion = fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp); if (feof(fp)) { - Log() << "Error reading version number on " << f->filename << ": End of file detected."; + Anope::Logger.Log("Error reading version number on {0}: End of file detected.", f->filename); delete f; return NULL; } else if (myversion < version) { - Log() << "Unsuported database version (" << myversion << ") on " << f->filename << "."; + Anope::Logger.Log("Unsuported database version ({0}) on {1}.", myversion, f->filename); delete f; return NULL; } @@ -644,7 +644,7 @@ static void LoadNicks() READ(read_uint16(&u16, f)); READ(read_int16(&i16, f)); - Log(LOG_DEBUG) << "Loaded NickServ::Account " << nc->GetDisplay(); + Anope::Logger.Debug("Loaded nickserv account {0}", nc->GetDisplay()); } for (int i = 0; i < 1024; ++i) @@ -672,7 +672,7 @@ static void LoadNicks() NickServ::Account *nc = NickServ::FindAccount(core); if (nc == NULL) { - Log() << "Skipping coreless nick " << nick << " with core " << core; + Anope::Logger.Debug("Skipping coreless nick {0} with core {1}", nick, core); continue; } @@ -709,7 +709,7 @@ static void LoadNicks() if (tmpu16 & OLD_NS_NO_EXPIRE) na->SetNoExpire(true); - Log(LOG_DEBUG) << "Loaded NickServ::Nick " << na->GetNick(); + Anope::Logger.Debug("Loaded nick {0}", na->GetNick()); } close_db(f); /* End of section Ia */ @@ -735,7 +735,7 @@ static void LoadVHosts() NickServ::Nick *na = NickServ::FindNick(nick); if (na == NULL) { - Log() << "Removing vhost for non-existent nick " << nick; + Anope::Logger.Log("Removing vhost for non-existent nick {0}", nick); continue; } @@ -749,7 +749,7 @@ static void LoadVHosts() vhost->SetCreator(creator); vhost->SetCreated(vtime); - Log() << "Loaded vhost for " << na->GetNick(); + Anope::Logger.Debug("Loaded vhost for {0}", na->GetNick()); } close_db(f); @@ -787,7 +787,7 @@ static void LoadBots() if (flags & OLD_BI_PRIVATE) bi->bi->SetOperOnly(true); - Log(LOG_DEBUG) << "Loaded bot " << bi->nick; + Anope::Logger.Debug("Loaded bot {0}", bi->nick); } close_db(f); @@ -1173,7 +1173,7 @@ static void LoadChannels() continue; } - Log(LOG_DEBUG) << "Loaded channel " << ci->GetName(); + Anope::Logger.Debug("Loaded channel {0}", ci->GetName()); } close_db(f); diff --git a/modules/database/redis.cpp b/modules/database/redis.cpp index 49ab8cbd4..b6ce95241 100644 --- a/modules/database/redis.cpp +++ b/modules/database/redis.cpp @@ -278,7 +278,7 @@ void TypeLoader::OnResult(const Reply &r) Serialize::Object *obj = type->Require(id); if (obj == nullptr) { - Log(LOG_DEBUG) << "redis: Unable to require object #" << id << " of type " << type->GetName(); + Anope::Logger.Debug("Unable to require object #{0} of type {1}", id, type->GetName()); continue; } @@ -318,7 +318,7 @@ void ObjectLoader::OnResult(const Reply &r) void FieldLoader::OnResult(const Reply &r) { - Log(LOG_DEBUG_2) << "redis: Setting field " << field->serialize_name << " of object #" << obj->id << " of type " << obj->GetSerializableType()->GetName() << " to " << r.bulk; + Anope::Logger.Debug2("Setting field {0} of object #{1} of type {2} to {3}", field->serialize_name, obj->id, obj->GetSerializableType()->GetName(), r.bulk); field->UnserializeFromString(obj, r.bulk); delete this; @@ -358,25 +358,27 @@ void SubscriptionListener::OnResult(const Reply &r) } catch (const ConvertException &ex) { - Log(LOG_DEBUG) << "redis: unable to get id for SL update key " << sid; + this->GetOwner()->logger.Debug("unable to get id for SL update key {0}", sid); return; } Serialize::Object *obj = Serialize::GetID(id); if (obj == nullptr) { - Log(LOG_DEBUG) << "redis: pmessage for unknown object #" << id; + this->GetOwner()->logger.Debug("message for unknown object #{0}", id); return; } Serialize::FieldBase *field = obj->GetSerializableType()->GetField(key); if (field == nullptr) { - Log(LOG_DEBUG) << "redis: pmessage for unknown field of object #" << id << ": " << key; + this->GetOwner()->logger.Debug("message for unknown field of object #{0}: {1}", id, key); return; } - Log(LOG_DEBUG_2) << "redis: Setting field " << field->serialize_name << " of object #" << obj->id << " of type " << obj->GetSerializableType()->GetName() << " to " << value; + this->GetOwner()->logger.Debug2("Setting field {0} of object #{1} of type {2} to {3}", + field->serialize_name, obj->id, obj->GetSerializableType()->GetName(), value); + field->UnserializeFromString(obj, value); } else if (command == "create") @@ -393,21 +395,21 @@ void SubscriptionListener::OnResult(const Reply &r) } catch (const ConvertException &ex) { - Log(LOG_DEBUG) << "redis: unable to get id for SL update key " << sid; + this->GetOwner()->logger.Debug("unable to get id for SL update key {0}", sid); return; } Serialize::TypeBase *type = Serialize::TypeBase::Find(stype); if (type == nullptr) { - Log(LOG_DEBUG) << "redis: pmessage create for nonexistant type " << stype; + this->GetOwner()->logger.Debug("message create for nonexistant type {0}", stype); return; } Serialize::Object *obj = type->Require(id); if (obj == nullptr) { - Log(LOG_DEBUG) << "redis: require for pmessage create type " << type->GetName() << " id #" << id << " returned nullptr"; + this->GetOwner()->logger.Debug("require for message create type {0} id #{1} returned nullptr", type->GetName(), id); return; } } @@ -424,21 +426,23 @@ void SubscriptionListener::OnResult(const Reply &r) } catch (const ConvertException &ex) { - Log(LOG_DEBUG) << "redis: unable to get id for SL update key " << sid; + this->GetOwner()->logger.Debug("unable to get id for SL update key {0}", sid); return; } Serialize::Object *obj = Serialize::GetID(id); if (obj == nullptr) { - Log(LOG_DEBUG) << "redis: message for unknown object #" << id; + this->GetOwner()->logger.Debug("message for unknown object #{0}", id); return; } obj->Delete(); } else - Log(LOG_DEBUG) << "redis: unknown message: " << message; + { + this->GetOwner()->logger.Debug("unknown message: {0}", message); + } } MODULE_INIT(DatabaseRedis) diff --git a/modules/database/sql.cpp b/modules/database/sql.cpp index 1739f168d..00c45a4bc 100644 --- a/modules/database/sql.cpp +++ b/modules/database/sql.cpp @@ -176,7 +176,7 @@ class DBSQL : public Module, public Pipe Serialize::Object *other = type->Require(id); if (other == nullptr) { - Log(LOG_DEBUG) << "Unable to require id " << id << " type " << type->GetName(); + Anope::Logger.Debug("Unable to require id {0} type {1}", id, type->GetName()); continue; } diff --git a/modules/dns.cpp b/modules/dns.cpp index 523b4044d..62659414a 100644 --- a/modules/dns.cpp +++ b/modules/dns.cpp @@ -43,7 +43,7 @@ class Packet : public Query if (pos + name.length() + 2 > output_size) throw SocketException("Unable to pack name"); - Log(LOG_DEBUG_2) << "Resolver: PackName packing " << name; + Anope::Logger.Debug2("resolver: PackName packing {0}", name); sepstream sep(name, '.'); Anope::string token; @@ -113,7 +113,7 @@ class Packet : public Query /* Empty names are valid (root domain) */ - Log(LOG_DEBUG_2) << "Resolver: UnpackName successfully unpacked " << name; + Anope::Logger.Debug2("resolver: UnpackName successfully unpacked {0}", name); return name; } @@ -203,7 +203,7 @@ class Packet : public Query break; } - Log(LOG_DEBUG_2) << "Resolver: " << record.name << " -> " << record.rdata; + Anope::Logger.Debug2("resolver: {0} -> {1}", record.name, record.rdata); return record; } @@ -252,7 +252,7 @@ class Packet : public Query unsigned short arcount = (input[packet_pos] << 8) | input[packet_pos + 1]; packet_pos += 2; - Log(LOG_DEBUG_2) << "Resolver: qdcount: " << qdcount << " ancount: " << ancount << " nscount: " << nscount << " arcount: " << arcount; + Anope::Logger.Debug2("resolver: qdcount {0} ancount: {1} nscount: {2} arcount: {3}", qdcount, ancount, nscount, arcount); for (unsigned i = 0; i < qdcount; ++i) this->questions.push_back(this->UnpackQuestion(input, len, packet_pos)); @@ -270,7 +270,7 @@ class Packet : public Query } catch (const SocketException &ex) { - Log(LOG_DEBUG_2) << "Unable to parse ns/ar records: " << ex.GetReason(); + Anope::Logger.Debug2("Unable to parse ns/ar records: {0}", ex.GetReason()); } } @@ -500,12 +500,12 @@ class TCPSocket : public ListenSocket Client(Manager *m, TCPSocket *l, int fd, const sockaddrs &addr) : Socket(fd, l->IsIPv6()), ClientSocket(l, addr), Timer(5), manager(m), packet(NULL), length(0) { - Log(LOG_DEBUG_2) << "Resolver: New client from " << addr.addr(); + Anope::Logger.Debug2("resolver: New client from {0}", addr.addr()); } ~Client() { - Log(LOG_DEBUG_2) << "Resolver: Exiting client from " << clientaddr.addr(); + Anope::Logger.Debug2("resolver: Exiting client from {0}", clientaddr.addr()); delete packet; } @@ -521,7 +521,7 @@ class TCPSocket : public ListenSocket bool ProcessRead() override { - Log(LOG_DEBUG_2) << "Resolver: Reading from DNS TCP socket"; + Anope::Logger.Debug2("resolver: reading from DNS TCP socket"); int i = recv(this->GetFD(), reinterpret_cast<char *>(packet_buffer) + length, sizeof(packet_buffer) - length, 0); if (i <= 0) @@ -541,7 +541,7 @@ class TCPSocket : public ListenSocket bool ProcessWrite() override { - Log(LOG_DEBUG_2) << "Resolver: Writing to DNS TCP socket"; + Anope::Logger.Debug2("resolver: Writing to DNS TCP socket"); if (packet != NULL) { @@ -600,7 +600,7 @@ class UDPSocket : public ReplySocket bool ProcessRead() override { - Log(LOG_DEBUG_2) << "Resolver: Reading from DNS UDP socket"; + Anope::Logger.Debug2("resolver: Reading from DNS UDP socket"); unsigned char packet_buffer[524]; sockaddrs from_server; @@ -611,7 +611,7 @@ class UDPSocket : public ReplySocket bool ProcessWrite() override { - Log(LOG_DEBUG_2) << "Resolver: Writing to DNS UDP socket"; + Anope::Logger.Debug2("resolver: Writing to DNS UDP socket"); Packet *r = !packets.empty() ? packets.front() : NULL; if (r != NULL) @@ -651,7 +651,7 @@ class NotifySocket : public Socket if (!packet) return false; - Log(LOG_DEBUG_2) << "Resolver: Notifying slave " << packet->addr.addr(); + Anope::Logger.Debug2("resolver: Notifying slave {0}", packet->addr.addr()); try { @@ -735,7 +735,7 @@ class MyManager : public Manager, public Timer } catch (const SocketException &ex) { - Log() << "Unable to bind dns to " << ip << ":" << port << ": " << ex.GetReason(); + Anope::Logger.Log("Unable to bind dns to {0}:{1}: {2}", ip, port, ex.GetReason()); } notify = n; @@ -759,11 +759,11 @@ class MyManager : public Manager, public Timer public: void Process(Request *req) override { - Log(LOG_DEBUG_2) << "Resolver: Processing request to lookup " << req->name << ", of type " << req->type; + Anope::Logger.Debug2("resolver: Processing request to lookup {0}, of type {1}", req->name, req->type); if (req->use_cache && this->CheckCache(req)) { - Log(LOG_DEBUG_2) << "Resolver: Using cached result"; + Anope::Logger.Debug2("resolver: Using cached result"); delete req; return; } @@ -802,7 +802,7 @@ class MyManager : public Manager, public Timer } catch (const SocketException &ex) { - Log(LOG_DEBUG_2) << ex.GetReason(); + Anope::Logger.Debug2(ex.GetReason()); return true; } @@ -812,7 +812,7 @@ class MyManager : public Manager, public Timer return true; else if (recv_packet.questions.empty()) { - Log(LOG_DEBUG_2) << "Resolver: Received a question with no questions?"; + Anope::Logger.Debug2("resolver: Received a question with no questions?"); return true; } @@ -868,26 +868,26 @@ class MyManager : public Manager, public Timer if (from == NULL) { - Log(LOG_DEBUG_2) << "Resolver: Received an answer over TCP. This is not supported."; + Anope::Logger.Debug2("resolver: Received an answer over TCP. This is not supported."); return true; } else if (this->addrs != *from) { - Log(LOG_DEBUG_2) << "Resolver: Received an answer from the wrong nameserver, Bad NAT or DNS forging attempt? '" << this->addrs.addr() << "' != '" << from->addr() << "'"; + Anope::Logger.Debug2("resolver: Received an answer from the wrong nameserver, Bad NAT or DNS forging attempt? '{0}' != '{1}'", this->addrs.addr(), from->addr()); return true; } std::map<unsigned short, Request *>::iterator it = this->requests.find(recv_packet.id); if (it == this->requests.end()) { - Log(LOG_DEBUG_2) << "Resolver: Received an answer for something we didn't request"; + Anope::Logger.Debug2("resolver: Received an answer for something we didn't request"); return true; } Request *request = it->second; if (recv_packet.flags & QUERYFLAGS_OPCODE) { - Log(LOG_DEBUG_2) << "Resolver: Received a nonstandard query"; + Anope::Logger.Debug2("resolver: Received a nonstandard query"); recv_packet.error = ERROR_NONSTANDARD_QUERY; request->OnError(&recv_packet); } @@ -898,23 +898,23 @@ class MyManager : public Manager, public Timer switch (recv_packet.flags & QUERYFLAGS_RCODE) { case 1: - Log(LOG_DEBUG_2) << "Resolver: format error"; + Anope::Logger.Debug2("resolver: format error"); error = ERROR_FORMAT_ERROR; break; case 2: - Log(LOG_DEBUG_2) << "Resolver: server error"; + Anope::Logger.Debug2("resolver: server error"); error = ERROR_SERVER_FAILURE; break; case 3: - Log(LOG_DEBUG_2) << "Resolver: domain not found"; + Anope::Logger.Debug2("resolver: domain not found"); error = ERROR_DOMAIN_NOT_FOUND; break; case 4: - Log(LOG_DEBUG_2) << "Resolver: not implemented"; + Anope::Logger.Debug2("resolver: not implemented"); error = ERROR_NOT_IMPLEMENTED; break; case 5: - Log(LOG_DEBUG_2) << "Resolver: refused"; + Anope::Logger.Debug2("resolver: refused"); error = ERROR_REFUSED; break; default: @@ -926,13 +926,13 @@ class MyManager : public Manager, public Timer } else if (recv_packet.questions.empty() || recv_packet.answers.empty()) { - Log(LOG_DEBUG_2) << "Resolver: No resource records returned"; + Anope::Logger.Debug2("resolver: no resource records returned"); recv_packet.error = ERROR_NO_RECORDS; request->OnError(&recv_packet); } else { - Log(LOG_DEBUG_2) << "Resolver: Lookup complete for " << request->name; + Anope::Logger.Debug2("resolver: lookup complete for {0}", request->name); request->OnLookupComplete(&recv_packet); this->AddCache(recv_packet); } @@ -984,7 +984,7 @@ class MyManager : public Manager, public Timer void Tick(time_t now) override { - Log(LOG_DEBUG_2) << "Resolver: Purging DNS cache"; + Anope::Logger.Debug2("resolver: purging DNS cache"); for (cache_map::iterator it = this->cache.begin(), it_next; it != this->cache.end(); it = it_next) { @@ -1005,7 +1005,7 @@ class MyManager : public Manager, public Timer void AddCache(Query &r) { const ResourceRecord &rr = r.answers[0]; - Log(LOG_DEBUG_3) << "Resolver cache: added cache for " << rr.name << " -> " << rr.rdata << ", ttl: " << rr.ttl; + Anope::Logger.Debug3("resolver: cache: added cache for {0} -> {1}, ttl: {2}", rr.name, rr.rdata, rr.ttl); this->cache[r.questions[0]] = r; } @@ -1018,7 +1018,7 @@ class MyManager : public Manager, public Timer if (it != this->cache.end()) { Query &record = it->second; - Log(LOG_DEBUG_3) << "Resolver: Using cached result for " << request->name; + Anope::Logger.Debug3("resolver: Using cached result for {0}", request->name); request->OnLookupComplete(&record); return true; } @@ -1097,7 +1097,7 @@ class ModuleDNS : public Module if (server.substr(i).is_pos_number_only()) { nameserver = server.substr(i); - Log(LOG_DEBUG) << "Nameserver set to " << nameserver; + Anope::Logger.Debug("resolver: nameserver set to {0}", nameserver); success = true; break; } @@ -1110,7 +1110,7 @@ class ModuleDNS : public Module if (!success) { - Log() << "Unable to find nameserver, defaulting to 127.0.0.1"; + Anope::Logger.Log("resolver: unable to find nameserver, defaulting to 127.0.0.1"); nameserver = "127.0.0.1"; } } diff --git a/modules/dnsbl.cpp b/modules/dnsbl.cpp index f8d35bf71..6b6186028 100644 --- a/modules/dnsbl.cpp +++ b/modules/dnsbl.cpp @@ -90,7 +90,7 @@ class DNSBLResolver : public Request reason = reason.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<Anope::string>("networkname")); ServiceBot *OperServ = Config->GetClient("OperServ"); - Log(creator, "dnsbl", OperServ) << user->GetMask() << " (" << addr << ") appears in " << this->blacklist.name; + creator->logger.Category("dnsbl").Bot(OperServ).Log(_("{0} ({1}) appears in {2}"), user->GetMask(), addr, this->blacklist.name); XLine *x = Serialize::New<XLine *>(); x->SetMask("*@" + addr); @@ -207,7 +207,7 @@ class ModuleDNSBL : public Module catch (const SocketException &ex) { delete res; - Log(this) << ex.GetReason(); + logger.Log(ex.GetReason()); } } } diff --git a/modules/encryption/bcrypt.cpp b/modules/encryption/bcrypt.cpp index 622fef745..3375e4bee 100644 --- a/modules/encryption/bcrypt.cpp +++ b/modules/encryption/bcrypt.cpp @@ -906,7 +906,7 @@ class EBCRYPT : public Module EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override { dest = "bcrypt:" + Generate(src, Salt()); - Log(LOG_DEBUG_2) << "(enc_bcrypt) hashed password from [" << src << "] to [" << dest << "]"; + logger.Debug2("hashed password from {0} to {1}", src, dest); return EVENT_ALLOW; } @@ -941,7 +941,7 @@ class EBCRYPT : public Module } catch (const ConvertException &) { - Log(this) << "Could not get the round size of a hash. This is probably a bug. Hash: " << nc->GetPassword(); + logger.Log("Could not get the round size of a hash. This is probably a bug. Hash: {0}", nc->GetPassword()); } if (ModuleManager::FindFirstOf(ENCRYPTION) != this || (hashrounds && hashrounds != rounds)) @@ -962,20 +962,20 @@ class EBCRYPT : public Module if (rounds == 0) { rounds = 10; - Log(this) << "Rounds can't be 0! Setting ignored."; + logger.Log("Rounds can't be 0! Setting ignored."); } else if (rounds < 10) { - Log(this) << "10 to 12 rounds is recommended."; + logger.Log("10 to 12 rounds is recommended."); } else if (rounds >= 32) { rounds = 10; - Log(this) << "The maximum number of rounds supported is 31. Ignoring setting and using 10."; + logger.Log("The maximum number of rounds supported is 31. Ignoring setting and using 10."); } else if (rounds >= 14) { - Log(this) << "Are you sure you want to use " << stringify(rounds) << " in your bcrypt settings? This is very CPU intensive! Recommended rounds is 10-12."; + logger.Log("Are you sure you want to use {0} in your bcrypt settings? This is very CPU intensive! Recommended rounds is 10-12.", rounds); } } }; diff --git a/modules/encryption/md5.cpp b/modules/encryption/md5.cpp index ca3bfcc9a..7dd92d92f 100644 --- a/modules/encryption/md5.cpp +++ b/modules/encryption/md5.cpp @@ -376,7 +376,7 @@ class EMD5 : public Module Anope::string buf = "md5:" + Anope::Hex(reinterpret_cast<const char *>(hash.first), hash.second); - Log(LOG_DEBUG_2) << "(enc_md5) hashed password from [" << src << "] to [" << buf << "]"; + logger.Debug2("hashed password from [{0}] to [{1}]", src, buf); dest = buf; return EVENT_ALLOW; } diff --git a/modules/encryption/none.cpp b/modules/encryption/none.cpp index 3b1f49d33..2e0ae8636 100644 --- a/modules/encryption/none.cpp +++ b/modules/encryption/none.cpp @@ -38,7 +38,7 @@ class ENone : public Module Anope::string cpass; Anope::B64Encode(src, cpass); buf += cpass; - Log(LOG_DEBUG_2) << "(enc_none) hashed password from [" << src << "] to [" << buf << "]"; + logger.Debug2("hashed password from [{0}] to [{1}]", src, buf); dest = buf; return EVENT_ALLOW; } diff --git a/modules/encryption/old.cpp b/modules/encryption/old.cpp index bfe7131bc..22065e441 100644 --- a/modules/encryption/old.cpp +++ b/modules/encryption/old.cpp @@ -92,7 +92,8 @@ class EOld : public Module Anope::string buf = "oldmd5:" + Anope::Hex(digest2, sizeof(digest2)); - Log(LOG_DEBUG_2) << "(enc_old) hashed password from [" << src << "] to [" << buf << "]"; + logger.Debug2("hashed password from [{0}] to [{1}]", src, buf); + dest = buf; delete context; return EVENT_ALLOW; diff --git a/modules/encryption/sha1.cpp b/modules/encryption/sha1.cpp index ea108f49c..1dcb2dc5e 100644 --- a/modules/encryption/sha1.cpp +++ b/modules/encryption/sha1.cpp @@ -238,7 +238,7 @@ class ESHA1 : public Module Anope::string buf = "sha1:" + Anope::Hex(reinterpret_cast<const char *>(hash.first), hash.second); - Log(LOG_DEBUG_2) << "(enc_sha1) hashed password from [" << src << "] to [" << buf << "]"; + logger.Debug2("hashed password from [{0}] to [{1}]", src, buf); dest = buf; return EVENT_ALLOW; } diff --git a/modules/encryption/sha256.cpp b/modules/encryption/sha256.cpp index e05629a50..8226cb792 100644 --- a/modules/encryption/sha256.cpp +++ b/modules/encryption/sha256.cpp @@ -302,7 +302,7 @@ class ESHA256 : public Module std::stringstream buf; buf << "sha256:" << Anope::Hex(reinterpret_cast<const char *>(hash.first), hash.second) << ":" << GetIVString(); - Log(LOG_DEBUG_2) << "(enc_sha256) hashed password from [" << src << "] to [" << buf.str() << " ]"; + logger.Debug2("hashed password from [{0}] to [{1}]", src, buf.str()); dest = buf.str(); return EVENT_ALLOW; } diff --git a/modules/extra/ldap.cpp b/modules/extra/ldap.cpp index 6d4c0bd62..b5c37d7cf 100644 --- a/modules/extra/ldap.cpp +++ b/modules/extra/ldap.cpp @@ -479,7 +479,7 @@ class ModuleLDAP : public Module, public Pipe if (i == conf->CountBlock("ldap")) { - Log(LOG_NORMAL, "ldap") << "LDAP: Removing server connection " << cname; + Log(LogType::NORMAL, "ldap") << "LDAP: Removing server connection " << cname; s->SetExitState(); s->Wakeup(); @@ -507,11 +507,11 @@ class ModuleLDAP : public Module, public Pipe ss->Start(); this->LDAPServices.insert(std::make_pair(connname, ss)); - Log(LOG_NORMAL, "ldap") << "LDAP: Successfully initialized server " << connname << " (" << server << ")"; + Log(LogType::NORMAL, "ldap") << "LDAP: Successfully initialized server " << connname << " (" << server << ")"; } catch (const LDAPException &ex) { - Log(LOG_NORMAL, "ldap") << "LDAP: " << ex.GetReason(); + Log(LogType::NORMAL, "ldap") << "LDAP: " << ex.GetReason(); } } } diff --git a/modules/extra/ldap_authentication.cpp b/modules/extra/ldap_authentication.cpp index 8160eb6e2..722284fb4 100644 --- a/modules/extra/ldap_authentication.cpp +++ b/modules/extra/ldap_authentication.cpp @@ -80,7 +80,7 @@ class IdentifyInterface : public LDAPInterface { const LDAPAttributes &attr = r.get(0); ii->dn = attr.get("dn"); - Log(LOG_DEBUG) << "m_ldap_authenticationn: binding as " << ii->dn; + Log(LogType::DEBUG) << "m_ldap_authenticationn: binding as " << ii->dn; ii->lprov->Bind(new IdentifyInterface(this->owner, ii), ii->dn, ii->req->GetPassword()); ii = NULL; @@ -99,7 +99,7 @@ class IdentifyInterface : public LDAPInterface Anope::string sf = search_filter.replace_all_cs("%account", ii->req->GetAccount()).replace_all_cs("%object_class", object_class); try { - Log(LOG_DEBUG) << "m_ldap_authentication: searching for " << sf; + Log(LogType::DEBUG) << "m_ldap_authentication: searching for " << sf; ii->lprov->Search(new IdentifyInterface(this->owner, ii), basedn, sf); ii->admin_bind = false; ii = NULL; diff --git a/modules/extra/mysql.cpp b/modules/extra/mysql.cpp index a5d1ac163..66b4ffa85 100644 --- a/modules/extra/mysql.cpp +++ b/modules/extra/mysql.cpp @@ -241,7 +241,7 @@ class ModuleSQL : public Module if (i == config->CountBlock("mysql")) { - Log(LOG_NORMAL, "mysql") << "MySQL: Removing server connection " << cname; + Log(LogType::NORMAL, "mysql") << "MySQL: Removing server connection " << cname; delete s; this->MySQLServices.erase(cname); @@ -266,11 +266,11 @@ class ModuleSQL : public Module MySQLService *ss = new MySQLService(this, connname, database, server, user, password, port); this->MySQLServices.insert(std::make_pair(connname, ss)); - Log(LOG_NORMAL, "mysql") << "MySQL: Successfully connected to server " << connname << " (" << server << ")"; + Log(LogType::NORMAL, "mysql") << "MySQL: Successfully connected to server " << connname << " (" << server << ")"; } catch (const SQL::Exception &ex) { - Log(LOG_NORMAL, "mysql") << "MySQL: " << ex.GetReason(); + Log(LogType::NORMAL, "mysql") << "MySQL: " << ex.GetReason(); } } } @@ -542,7 +542,7 @@ void MySQLService::Connect() if (!connect) throw SQL::Exception("Unable to connect to MySQL service " + this->GetName() + ": " + mysql_error(this->sql)); - Log(LOG_DEBUG) << "Successfully connected to MySQL service " << this->GetName() << " at " << this->server << ":" << this->port; + Log(LogType::DEBUG) << "Successfully connected to MySQL service " << this->GetName() << " at " << this->server << ":" << this->port; } diff --git a/modules/extra/sql_authentication.cpp b/modules/extra/sql_authentication.cpp index 98128d325..0ea457ea3 100644 --- a/modules/extra/sql_authentication.cpp +++ b/modules/extra/sql_authentication.cpp @@ -43,12 +43,12 @@ class SQLAuthenticationResult : public SQL::Interface { if (r.Rows() == 0) { - Log(LOG_DEBUG) << "m_sql_authentication: Unsuccessful authentication for " << req->GetAccount(); + Log(LogType::DEBUG) << "m_sql_authentication: Unsuccessful authentication for " << req->GetAccount(); delete this; return; } - Log(LOG_DEBUG) << "m_sql_authentication: Successful authentication for " << req->GetAccount(); + Log(LogType::DEBUG) << "m_sql_authentication: Successful authentication for " << req->GetAccount(); Anope::string email; try @@ -155,7 +155,7 @@ class ModuleSQLAuthentication : public Module this->SQL->Run(new SQLAuthenticationResult(u, req), q); - Log(LOG_DEBUG) << "m_sql_authentication: Checking authentication for " << req->GetAccount(); + Log(LogType::DEBUG) << "m_sql_authentication: Checking authentication for " << req->GetAccount(); } }; diff --git a/modules/extra/sql_log.cpp b/modules/extra/sql_log.cpp index 320350ced..d561a0fb2 100644 --- a/modules/extra/sql_log.cpp +++ b/modules/extra/sql_log.cpp @@ -79,28 +79,28 @@ class SQLLog : public Module switch (l->type) { - case LOG_ADMIN: + case LogType::ADMIN: insert.SetValue("type", "ADMIN"); break; - case LOG_OVERRIDE: + case LogType::OVERRIDE: insert.SetValue("type", "OVERRIDE"); break; - case LOG_COMMAND: + case LogType::COMMAND: insert.SetValue("type", "COMMAND"); break; - case LOG_SERVER: + case LogType::SERVER: insert.SetValue("type", "SERVER"); break; - case LOG_CHANNEL: + case LogType::CHANNEL: insert.SetValue("type", "CHANNEL"); break; - case LOG_USER: + case LogType::USER: insert.SetValue("type", "USER"); break; - case LOG_MODULE: + case LogType::MODULE: insert.SetValue("type", "MODULE"); break; - case LOG_NORMAL: + case LogType::NORMAL: insert.SetValue("type", "NORMAL"); break; default: diff --git a/modules/extra/sql_oper.cpp b/modules/extra/sql_oper.cpp index 9dfcfe772..4beb3d39f 100644 --- a/modules/extra/sql_oper.cpp +++ b/modules/extra/sql_oper.cpp @@ -55,7 +55,7 @@ class SQLOperResult : public SQL::Interface if (r.Rows() == 0) { - Log(LOG_DEBUG) << "m_sql_oper: Got 0 rows for " << user->nick; + Log(LogType::DEBUG) << "m_sql_oper: Got 0 rows for " << user->nick; Deoper(); return; } @@ -71,7 +71,7 @@ class SQLOperResult : public SQL::Interface return; } - Log(LOG_DEBUG) << "m_sql_oper: Got result for " << user->nick << ", opertype " << opertype; + Log(LogType::DEBUG) << "m_sql_oper: Got result for " << user->nick << ", opertype " << opertype; Anope::string modes; try @@ -163,7 +163,7 @@ class ModuleSQLOper : public Module this->SQL->Run(new SQLOperResult(this, u), q); - Log(LOG_DEBUG) << "m_sql_oper: Checking authentication for " << u->Account()->GetDisplay(); + Log(LogType::DEBUG) << "m_sql_oper: Checking authentication for " << u->Account()->GetDisplay(); } }; diff --git a/modules/extra/ssl_gnutls.cpp b/modules/extra/ssl_gnutls.cpp index 223b72519..eecd6825e 100644 --- a/modules/extra/ssl_gnutls.cpp +++ b/modules/extra/ssl_gnutls.cpp @@ -371,7 +371,7 @@ class GnuTLSModule : public Module delete newcred; throw; } - Log(LOG_DEBUG) << "m_ssl_gnutls: Successfully loaded DH parameters from " << dhfile; + Log(LogType::DEBUG) << "m_ssl_gnutls: Successfully loaded DH parameters from " << dhfile; } if (cred) @@ -379,7 +379,7 @@ class GnuTLSModule : public Module cred = newcred; cred->incrref(); - Log(LOG_DEBUG) << "m_ssl_gnutls: Successfully loaded certificate " << certfile << " and private key " << keyfile; + Log(LogType::DEBUG) << "m_ssl_gnutls: Successfully loaded certificate " << certfile << " and private key " << keyfile; } void OnPreServerConnect() override diff --git a/modules/extra/ssl_openssl.cpp b/modules/extra/ssl_openssl.cpp index 22f421d35..20673b5ef 100644 --- a/modules/extra/ssl_openssl.cpp +++ b/modules/extra/ssl_openssl.cpp @@ -163,7 +163,7 @@ class SSLModule : public Module if (!SSL_CTX_use_certificate_chain_file(client_ctx, this->certfile.c_str()) || !SSL_CTX_use_certificate_chain_file(server_ctx, this->certfile.c_str())) throw ConfigException("Error loading certificate"); else - Log(LOG_DEBUG) << "m_ssl_openssl: Successfully loaded certificate " << this->certfile; + Log(LogType::DEBUG) << "m_ssl_openssl: Successfully loaded certificate " << this->certfile; } else Log() << "Unable to open certificate " << this->certfile; @@ -173,7 +173,7 @@ class SSLModule : public Module if (!SSL_CTX_use_PrivateKey_file(client_ctx, this->keyfile.c_str(), SSL_FILETYPE_PEM) || !SSL_CTX_use_PrivateKey_file(server_ctx, this->keyfile.c_str(), SSL_FILETYPE_PEM)) throw ConfigException("Error loading private key"); else - Log(LOG_DEBUG) << "m_ssl_openssl: Successfully loaded private key " << this->keyfile; + Log(LogType::DEBUG) << "m_ssl_openssl: Successfully loaded private key " << this->keyfile; } else { diff --git a/modules/extra/stats/chanstats.cpp b/modules/extra/stats/chanstats.cpp index 65a198449..adc002c8c 100644 --- a/modules/extra/stats/chanstats.cpp +++ b/modules/extra/stats/chanstats.cpp @@ -34,11 +34,11 @@ class CommandCSSetChanstats : public Command { ci->Extend<bool>("CS_STATS"); source.Reply(_("Chanstats statistics are now enabled for this channel.")); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable chanstats"; + Log(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, this, ci) << "to enable chanstats"; } else if (params[1].equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable chanstats"; + Log(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, this, ci) << "to disable chanstats"; ci->Shrink<bool>("CS_STATS"); source.Reply(_("Chanstats statistics are now disabled for this channel.")); } @@ -79,7 +79,7 @@ class CommandNSSetChanstats : public Command if (param.equals_ci("ON")) { - Log(na->GetAccount() == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable chanstats for " << na->GetAccount()->GetDisplay(); + Log(na->GetAccount() == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, this) << "to enable chanstats for " << na->GetAccount()->GetDisplay(); na->GetAccount()->Extend<bool>("NS_STATS"); if (saset) source.Reply(_("Chanstats statistics are now enabled for %s"), na->GetAccount()->GetDisplay().c_str()); @@ -88,7 +88,7 @@ class CommandNSSetChanstats : public Command } else if (param.equals_ci("OFF")) { - Log(na->GetAccount() == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable chanstats for " << na->GetAccount()->GetDisplay(); + Log(na->GetAccount() == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, this) << "to disable chanstats for " << na->GetAccount()->GetDisplay(); na->GetAccount()->Shrink<bool>("NS_STATS"); if (saset) source.Reply(_("Chanstats statistics are now disabled for %s"), na->GetAccount()->GetDisplay().c_str()); @@ -148,9 +148,9 @@ class MySQLInterface : public SQL::Interface void OnError(const SQL::Result &r) override { if (!r.GetQuery().query.empty()) - Log(LOG_DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError(); + Log(LogType::DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError(); else - Log(LOG_DEBUG) << "Chanstats: Error executing query: " << r.GetError(); + Log(LogType::DEBUG) << "Chanstats: Error executing query: " << r.GetError(); } }; diff --git a/modules/extra/stats/cs_fantasy_stats.cpp b/modules/extra/stats/cs_fantasy_stats.cpp index 78dce14f1..1cbc4cd15 100644 --- a/modules/extra/stats/cs_fantasy_stats.cpp +++ b/modules/extra/stats/cs_fantasy_stats.cpp @@ -24,9 +24,9 @@ class MySQLInterface : public SQL::Interface void OnError(const SQL::Result &r) override { if (!r.GetQuery().query.empty()) - Log(LOG_DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError(); + Log(LogType::DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError(); else - Log(LOG_DEBUG) << "Chanstats: Error executing query: " << r.GetError(); + Log(LogType::DEBUG) << "Chanstats: Error executing query: " << r.GetError(); } }; @@ -157,7 +157,7 @@ class CSStats : public Module } catch (const SQL::Exception &ex) { - Log(LOG_DEBUG) << ex.GetReason(); + Log(LogType::DEBUG) << ex.GetReason(); } } diff --git a/modules/extra/stats/cs_fantasy_top.cpp b/modules/extra/stats/cs_fantasy_top.cpp index 961b2f903..2be1d2f1c 100644 --- a/modules/extra/stats/cs_fantasy_top.cpp +++ b/modules/extra/stats/cs_fantasy_top.cpp @@ -24,9 +24,9 @@ class MySQLInterface : public SQL::Interface void OnError(const SQL::Result &r) override { if (!r.GetQuery().query.empty()) - Log(LOG_DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError(); + Log(LogType::DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError(); else - Log(LOG_DEBUG) << "Chanstats: Error executing query: " << r.GetError(); + Log(LogType::DEBUG) << "Chanstats: Error executing query: " << r.GetError(); } }; @@ -160,7 +160,7 @@ class CSTop : public Module } catch (const SQL::Exception &ex) { - Log(LOG_DEBUG) << ex.GetReason(); + Log(LogType::DEBUG) << ex.GetReason(); } } }; diff --git a/modules/fantasy.cpp b/modules/fantasy.cpp index 63fa7c5c5..7a9ea99f8 100644 --- a/modules/fantasy.cpp +++ b/modules/fantasy.cpp @@ -56,7 +56,7 @@ class CommandBSSetFantasy : public Command if (value.equals_ci("ON")) { bool override = !source.AccessFor(ci).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable fantasy"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable fantasy")); ci->SetFantasy(true); source.Reply(_("Fantasy mode is now \002on\002 on channel \002{0}\002."), ci->GetName()); @@ -64,7 +64,7 @@ class CommandBSSetFantasy : public Command else if (value.equals_ci("OFF")) { bool override = !source.AccessFor(ci).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable fantasy"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable fantasy")); ci->SetFantasy(false); source.Reply(_("Fantasy mode is now \002off\002 on channel \002{0}\002."), ci->GetName()); @@ -161,7 +161,7 @@ class Fantasy : public Module ServiceReference<Command> cmd(info.name); if (!cmd) { - Log(LOG_DEBUG) << "Fantasy command " << it->first << " exists for non-existent service " << info.name << "!"; + logger.Debug("Fantasy command {0} exists for non-existent service {1}!", it->first, info.name); return; } diff --git a/modules/global/global.cpp b/modules/global/global.cpp index af4add942..1d7ff7073 100644 --- a/modules/global/global.cpp +++ b/modules/global/global.cpp @@ -41,7 +41,8 @@ class CommandGLGlobal : public Command return; } - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to send {0}"), msg); + service->SendGlobal(NULL, source.GetNick(), msg); } diff --git a/modules/greet.cpp b/modules/greet.cpp index 58d37d4c4..52591f7f5 100644 --- a/modules/greet.cpp +++ b/modules/greet.cpp @@ -58,7 +58,7 @@ class CommandBSSetGreet : public Command if (value.equals_ci("ON")) { bool override = !source.AccessFor(ci).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable greets"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable greets")); ci->SetGreet(true); source.Reply(_("Greet mode for \002{0}\002 is now \002on\002."), ci->GetName()); @@ -66,7 +66,7 @@ class CommandBSSetGreet : public Command else if (value.equals_ci("OFF")) { bool override = !source.AccessFor(ci).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable greets"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable greets")); ci->SetGreet(false); source.Reply(_("Greet mode for \002{0}\002 is now \002off\002."), ci->GetName()); @@ -115,13 +115,15 @@ class CommandNSSetGreet : public Command if (!param.empty()) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the greet of " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to change the greet of {0}"), nc->GetDisplay()); + nc->SetGreet(param); source.Reply(_("Greet message for \002{0}\002 changed to \002{1}\002."), nc->GetDisplay(), param); } else { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to unset the greet of " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to unset the greet of {0}"), nc->GetDisplay()); + nc->SetGreet(""); source.Reply(_("Greet message for \002{0}\002 unset."), nc->GetDisplay()); } diff --git a/modules/hostserv/add.cpp b/modules/hostserv/add.cpp index f9388c975..3448dbc41 100644 --- a/modules/hostserv/add.cpp +++ b/modules/hostserv/add.cpp @@ -101,7 +101,7 @@ class CommandHSAdd : public Command } Anope::string mask = (!user.empty() ? user + "@" : "") + host; - Log(LOG_ADMIN, source, this) << "to add the vhost " << mask << " to " << na->GetAccount()->GetDisplay(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add the vhost {0} to {1}"), mask, na->GetAccount()->GetDisplay()); HostServ::VHost *vhost = Serialize::New<HostServ::VHost *>(); if (vhost == nullptr) diff --git a/modules/hostserv/del.cpp b/modules/hostserv/del.cpp index 4d754ac1b..a72c61c9a 100644 --- a/modules/hostserv/del.cpp +++ b/modules/hostserv/del.cpp @@ -54,7 +54,7 @@ class CommandHSDel : public Command return; } - Log(LOG_ADMIN, source, this) << "on " << na->GetAccount()->GetDisplay() << " to remove vhost " << vhost->Mask(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} to remove vhost {1}"), na->GetAccount()->GetDisplay(), vhost->Mask()); source.Reply(_("Vhost \002{0}\002 for \002{1}\002 has been removed."), vhost->Mask(), na->GetAccount()->GetDisplay()); vhost->Delete(); return; @@ -67,7 +67,8 @@ class CommandHSDel : public Command return; } - Log(LOG_ADMIN, source, this) << "on " << na->GetAccount()->GetDisplay(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0}"), na->GetAccount()->GetDisplay()); + #warning "send account" EventManager::Get()->Dispatch(&Event::DeleteVhost::OnDeleteVhost, na); diff --git a/modules/hostserv/off.cpp b/modules/hostserv/off.cpp index e1af7def4..861fd00b8 100644 --- a/modules/hostserv/off.cpp +++ b/modules/hostserv/off.cpp @@ -43,7 +43,7 @@ class CommandHSOff : public Command // XXX vident? u->vhost.clear(); IRCD->Send<messages::VhostDel>(u); - Log(LOG_COMMAND, source, this) << "to disable their vhost"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to disable their vhost")); source.Reply(_("Your vhost was removed and the normal cloaking restored.")); } diff --git a/modules/hostserv/on.cpp b/modules/hostserv/on.cpp index 3041f65a5..556b2f567 100644 --- a/modules/hostserv/on.cpp +++ b/modules/hostserv/on.cpp @@ -59,7 +59,7 @@ class CommandHSOn : public Command source.Reply(_("Your vhost of \002{0}\002 is now activated."), vhost->Mask()); - Log(LOG_COMMAND, source, this) << "to enable their vhost of " << vhost->Mask(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to enable their vhost of {0}"), vhost->Mask()); IRCD->Send<messages::VhostSet>(u, vhost->GetIdent(), vhost->GetHost()); u->vhost = vhost->GetHost(); if (IRCD->CanSetVIdent && !vhost->GetIdent().empty()) diff --git a/modules/hostserv/request.cpp b/modules/hostserv/request.cpp index 9508a9abc..bef1f1548 100644 --- a/modules/hostserv/request.cpp +++ b/modules/hostserv/request.cpp @@ -232,7 +232,7 @@ class CommandHSRequest : public Command source.Reply(_("Your vhost has been requested.")); this->SendMemos(source, user, host); - Log(LOG_COMMAND, source, this) << "to request new vhost " << (!user.empty() ? user + "@" : "") << host; + logger.Command(LogType::COMMAND, source, _("{source} used {command} to request new vhost {0}"), (!user.empty() ? user + "@" : "") + host); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -303,7 +303,8 @@ class CommandHSActivate : public Command memoserv->Send(source.service->nick, na->GetNick(), _("[auto memo] Your requested vHost has been approved."), true); source.Reply(_("Vhost for \002{0}\002 has been activated."), na->GetNick()); - Log(LOG_COMMAND, source, this) << "for " << na->GetNick() << " for vhost " << (!req->GetIdent().empty() ? req->GetIdent() + "@" : "") << req->GetHost(); + logger.Command(LogType::COMMAND, source, _("{source} used {command} for {0} for vhost {1}"), + na->GetNick(), (!req->GetIdent().empty() ? req->GetIdent() + "@" : "") + req->GetHost()); req->Delete(); } @@ -367,7 +368,8 @@ class CommandHSReject : public Command } source.Reply(_("Vhost for \002{0}\002 has been rejected."), na->GetNick()); - Log(LOG_COMMAND, source, this) << "to reject vhost for " << nick << " (" << (!reason.empty() ? reason : "no reason") << ")"; + logger.Command(LogType::COMMAND, source, _("{source} used {command} to reject vhost for {0} ({1})"), + na->GetNick(), !reason.empty() ? reason : "no reason"); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/hostserv/set.cpp b/modules/hostserv/set.cpp index f66c42d8a..8162fa80d 100644 --- a/modules/hostserv/set.cpp +++ b/modules/hostserv/set.cpp @@ -113,6 +113,8 @@ class CommandHSSetDefault : public Command vhost->SetDefault(true); source.Reply(_("Your default vhost is now \002{0}\002."), vhost->Mask()); + + logger.Command(LogType::COMMAND, source, _("{source} used {command} set their default vhost to {0}"), vhost->Mask()); } bool OnHelp(CommandSource &source, const Anope::string &) override diff --git a/modules/httpd.cpp b/modules/httpd.cpp index 41cd4a4ec..cdbca9d05 100644 --- a/modules/httpd.cpp +++ b/modules/httpd.cpp @@ -84,13 +84,13 @@ class MyHTTPClient : public HTTPClient if (this->message.headers.count(token)) { this->ip = this->message.headers[token]; - Log(LOG_DEBUG, "httpd") << "m_httpd: IP for connection " << this->GetFD() << " changed to " << this->ip; + Anope::Logger.Category("httpd").Debug("IP for connection {0} changed to {1}", this->GetFD(), this->ip); break; } } } - Log(LOG_DEBUG, "httpd") << "m_httpd: Serving page " << this->page_name << " to " << this->ip; + Anope::Logger.Category("httpd").Debug("Serving page {0} to {1}", this->page_name, this->ip); HTTPReply reply; reply.content_type = this->page->GetContentType(); @@ -104,12 +104,12 @@ class MyHTTPClient : public HTTPClient MyHTTPClient(HTTPProvider *l, int f, const sockaddrs &a) : Socket(f, l->IsIPv6()), HTTPClient(l, f, a), provider(l), header_done(false), served(false), ip(a.addr()), content_length(0), created(Anope::CurTime) { - Log(LOG_DEBUG, "httpd") << "Accepted connection " << f << " from " << a.addr(); + Anope::Logger.Category("httpd").Debug("Accepted connection {0} from {1}", f, a.addr()); } ~MyHTTPClient() { - Log(LOG_DEBUG, "httpd") << "Closing connection " << this->GetFD() << " from " << this->ip; + Anope::Logger.Category("httpd").Debug("Closing connection {0} from {1}", this->GetFD(), this->ip); } /* Close connection once all data is written */ @@ -152,7 +152,7 @@ class MyHTTPClient : public HTTPClient if (sz == Anope::string::npos || !sz || sz + 1 >= token.length()) continue; this->message.post_data[token.substr(0, sz)] = HTTPUtils::URLDecode(token.substr(sz + 1)); - Log(LOG_DEBUG_2) << "HTTP POST from " << this->clientaddr.addr() << ": " << token.substr(0, sz) << ": " << this->message.post_data[token.substr(0, sz)]; + Anope::Logger.Debug2("HTTP POST from {0}: {1}: {2}", this->clientaddr.addr(), token.substr(0, sz), this->message.post_data[token.substr(0, sz)]); } this->Serve(); @@ -163,7 +163,7 @@ class MyHTTPClient : public HTTPClient bool Read(const Anope::string &buf) { - Log(LOG_DEBUG_2) << "HTTP from " << this->clientaddr.addr() << ": " << buf; + Anope::Logger.Debug2("HTTP from {0}: {1}", this->clientaddr.addr(), buf); if (message.method == httpd::Method::NONE) { @@ -409,12 +409,12 @@ class HTTPD : public Module if (ip.empty()) { - Log(this) << "You must configure a bind IP for HTTP server " << hname; + logger.Log("You must configure a bind IP for HTTP server {0}", hname); continue; } else if (port <= 0 || port > 65535) { - Log(this) << "You must configure a (valid) listen port for HTTP server " << hname; + logger.Log("You must configure a (valid) listen port for HTTP server {0}", hname); continue; } @@ -429,12 +429,12 @@ class HTTPD : public Module } catch (const SocketException &ex) { - Log(this) << "Unable to create HTTP server " << hname << ": " << ex.GetReason(); + logger.Log("Unable to create HTTP server {0}: {1}", hname, ex.GetReason()); continue; } this->providers[hname] = p; - Log(this) << "Created HTTP server " << hname; + logger.Log("Created HTTP server {0}", hname); } else { @@ -445,7 +445,7 @@ class HTTPD : public Module delete p; this->providers.erase(hname); - Log(this) << "Changing HTTP server " << hname << " to " << ip << ":" << port; + logger.Log("Changing HTTP server {0} to {1}:{2}", hname, ip, port); try { @@ -455,7 +455,7 @@ class HTTPD : public Module } catch (const SocketException &ex) { - Log(this) << "Unable to create HTTP server " << hname << ": " << ex.GetReason(); + logger.Log("Unable to create HTTP server {0}: {1}", hname, ex.GetReason()); continue; } @@ -475,7 +475,7 @@ class HTTPD : public Module if (existing.count(p->GetName()) == 0) { - Log(this) << "Removing HTTP server " << p->GetName(); + logger.Log("Removing HTTP server {0}", p->GetName()); this->providers.erase(p->GetName()); delete p; } diff --git a/modules/memoserv/send.cpp b/modules/memoserv/send.cpp index 4cdbc0eb3..fdde189f9 100644 --- a/modules/memoserv/send.cpp +++ b/modules/memoserv/send.cpp @@ -53,7 +53,7 @@ class CommandMSSend : public Command if (result == MemoServ::MemoServService::MEMO_SUCCESS) { source.Reply(_("Memo sent to \002%s\002."), nick.c_str()); - Log(LOG_COMMAND, source, this) << "to send a memo to " << nick; + logger.Command(LogType::COMMAND, source, _("{source} used {command} to send a memo to {0}"), nick); } else if (result == MemoServ::MemoServService::MEMO_INVALID_TARGET) { diff --git a/modules/memoserv/sendall.cpp b/modules/memoserv/sendall.cpp index 9ab2a649e..d0b815560 100644 --- a/modules/memoserv/sendall.cpp +++ b/modules/memoserv/sendall.cpp @@ -36,7 +36,7 @@ class CommandMSSendAll : public Command const Anope::string &text = params[0]; - Log(LOG_ADMIN, source, this) << "to send " << text; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to send {0}"), text); for (NickServ::Account *nc : NickServ::service->GetAccountList()) if (nc != source.nc) diff --git a/modules/nickserv/access.cpp b/modules/nickserv/access.cpp index e20d81037..8c6ac0343 100644 --- a/modules/nickserv/access.cpp +++ b/modules/nickserv/access.cpp @@ -107,7 +107,7 @@ class CommandNSAccess : public Command a->SetAccount(nc); a->SetMask(mask); - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to ADD mask " << mask << " to " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to add mask {0} to {1}"), mask, nc->GetDisplay()); source.Reply(_("\002{0}\002 added to the access list of \002{1}\002."), mask, nc->GetDisplay()); } @@ -129,7 +129,9 @@ class CommandNSAccess : public Command if (a->GetMask().equals_ci(mask)) { a->Delete(); - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to DELETE mask " << mask << " from " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, + _("{source} used {command} to delete mask {0} from {1}"), + mask, nc->GetDisplay()); source.Reply(_("\002{0}\002 deleted from the access list of \002{1}\002."), mask, nc->GetDisplay()); return; } @@ -264,7 +266,7 @@ class NSAccess : public Module { NickAccess *a = Serialize::New<NickAccess *>(); a->SetAccount(na->GetAccount()); - a->SetMask(u->Mask()); + a->SetMask(u->WildMask()); u->SendMessage(Config->GetClient("NickServ"), _("\002{0}\002 has been registered under your hostmask: \002{1}\002"), na->GetNick(), a->GetMask()); diff --git a/modules/nickserv/ajoin.cpp b/modules/nickserv/ajoin.cpp index 0d708143c..bdb6c0522 100644 --- a/modules/nickserv/ajoin.cpp +++ b/modules/nickserv/ajoin.cpp @@ -181,7 +181,7 @@ class CommandNSAJoin : public Command return; addedchans = addedchans.substr(0, addedchans.length() - 2); - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to ADD channel " << addedchans << " to " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to add channel {2} from {3}"), addedchans, nc->GetDisplay()); source.Reply(_("\002{0}\002 added to the auto join list of \002{1}\002."), addedchans, nc->GetDisplay()); } @@ -218,7 +218,7 @@ class CommandNSAJoin : public Command return; delchans = delchans.substr(0, delchans.length() - 2); - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to DELETE channel " << delchans << " from " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to delete channel {2} from {3}"), delchans, nc->GetDisplay()); source.Reply(_("\002{0}\002 was removed from the auto join list of \002{1}\002."), delchans, nc->GetDisplay()); } diff --git a/modules/nickserv/cert.cpp b/modules/nickserv/cert.cpp index 51eae0fb0..d2e91bce6 100644 --- a/modules/nickserv/cert.cpp +++ b/modules/nickserv/cert.cpp @@ -187,8 +187,8 @@ class CommandNSCert : public Command e->SetCert(certfp); #warning "events?" + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to add certificate fingerprint {0} to {1}"), certfp, nc->GetDisplay()); - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to ADD certificate fingerprint " << certfp << " to " << nc->GetDisplay(); source.Reply(_("\002{0}\002 added to the certificate list of \002{1}\002."), certfp, nc->GetDisplay()); } @@ -218,7 +218,7 @@ class CommandNSCert : public Command cert->Delete(); - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to DELETE certificate fingerprint " << certfp << " from " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to delete certificate fingerprint {0} from {1}"), certfp, nc->GetDisplay()); source.Reply(_("\002{0}\002 deleted from the access list of \002{1}\002."), certfp, nc->GetDisplay()); } @@ -354,8 +354,9 @@ class NSCert : public Module else u->Login(nc); - u->SendMessage(NickServ, _("SSL certificate fingerprint accepted, you are now identified to \002%s\002."), nc->GetDisplay().c_str()); - Log(NickServ) << u->GetMask() << " automatically identified for account " << nc->GetDisplay() << " via SSL certificate fingerprint"; + u->SendMessage(NickServ, _("SSL certificate fingerprint accepted, you are now identified to \002{0}\002."), nc->GetDisplay()); + NickServ->logger.Log(_("{0} automatically identified for account {1} via SSL certificate fingerprint"), + u->GetMask(), nc->GetDisplay()); } EventReturn OnNickValidate(User *u, NickServ::Nick *na) override @@ -376,7 +377,8 @@ class NSCert : public Module u->Identify(na); u->SendMessage(NickServ, _("SSL certificate fingerprint accepted, you are now identified.")); - Log(NickServ) << u->GetMask() << " automatically identified for account " << na->GetAccount()->GetDisplay() << " via SSL certificate fingerprint"; + NickServ->logger.Log(_("{0} automatically identified for account {1} via SSL certificate fingerprint"), + u->GetMask(), na->GetAccount()->GetDisplay()); return EVENT_ALLOW; } diff --git a/modules/nickserv/drop.cpp b/modules/nickserv/drop.cpp index 426e3115e..d5a3f77b7 100644 --- a/modules/nickserv/drop.cpp +++ b/modules/nickserv/drop.cpp @@ -63,7 +63,10 @@ class CommandNSDrop : public Command EventManager::Get()->Dispatch(&Event::NickDrop::OnNickDrop, source, na); - Log(!is_mine ? LOG_ADMIN : LOG_COMMAND, source, this) << "to drop nickname " << na->GetNick() << " (group: " << na->GetAccount()->GetDisplay() << ") (email: " << (!na->GetAccount()->GetEmail().empty() ? na->GetAccount()->GetEmail() : "none") << ")"; + logger.Command(!is_mine ? LogType::ADMIN : LogType::COMMAND, source, _("{source} used {command} to drop nickname {0} (account: {1}) (e-mail: {2})"), + na->GetNick(), na->GetAccount()->GetDisplay(), + !na->GetAccount()->GetEmail().empty() ? na->GetAccount()->GetEmail() : "none"); + na->Delete(); source.Reply(_("\002{0}\002 has been dropped."), nick); diff --git a/modules/nickserv/getemail.cpp b/modules/nickserv/getemail.cpp index 0a996e7b0..ff7f9e8c1 100644 --- a/modules/nickserv/getemail.cpp +++ b/modules/nickserv/getemail.cpp @@ -33,7 +33,7 @@ class CommandNSGetEMail : public Command const Anope::string &email = params[0]; int j = 0; - Log(LOG_ADMIN, source, this) << "on " << email; + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0}"), email); for (NickServ::Account *nc : NickServ::service->GetAccountList()) if (!nc->GetEmail().empty() && Anope::Match(nc->GetEmail(), email)) diff --git a/modules/nickserv/group.cpp b/modules/nickserv/group.cpp index f5afb272e..cff53d320 100644 --- a/modules/nickserv/group.cpp +++ b/modules/nickserv/group.cpp @@ -56,7 +56,10 @@ class NSGroupRequestListener : public NickServ::IdentifyRequestListener u->Login(target->GetAccount()); EventManager::Get()->Dispatch(&Event::NickGroup::OnNickGroup, u, target); - Log(LOG_COMMAND, source, cmd) << "to make " << nick << " join group of " << target->GetNick() << " (" << target->GetAccount()->GetDisplay() << ") (email: " << (!target->GetAccount()->GetEmail().empty() ? target->GetAccount()->GetEmail() : "none") << ")"; + cmd->logger.Command(LogType::COMMAND, source, _("{source} used {command} to make {2} join group of {3} ({4}) (email: {5})"), + source.GetSource(), source.GetCommand(), nick, target->GetNick(), target->GetAccount()->GetDisplay(), + !target->GetAccount()->GetEmail().empty() ? target->GetAccount()->GetEmail() : "none"); + source.Reply(_("You are now in the group of \002{0}\002."), target->GetNick()); u->lastnickreg = Anope::CurTime; @@ -68,7 +71,7 @@ class NSGroupRequestListener : public NickServ::IdentifyRequestListener if (!source.GetUser()) return; - Log(LOG_COMMAND, source, cmd) << "and failed to group to " << target->GetNick(); + cmd->logger.Command(LogType::COMMAND, source, _("{source} used {command} and failed to group to {0}"), target->GetNick()); source.Reply(_("Password incorrect.")); source.GetUser()->BadPassword(); } @@ -149,7 +152,8 @@ class CommandNSGroup : public Command if (target->GetAccount()->HasFieldS("NS_SUSPENDED")) { - Log(LOG_COMMAND, source, this) << "and tried to group to suspended nick " << target->GetNick(); + logger.Command(LogType::COMMAND, source, _("{source} used {command} and tried to group to suspended nickname {0}"), target->GetNick()); + source.Reply(_("\002{0}\002 is suspended."), target->GetNick()); return; } diff --git a/modules/nickserv/identify.cpp b/modules/nickserv/identify.cpp index 13e578b69..a88c9c90b 100644 --- a/modules/nickserv/identify.cpp +++ b/modules/nickserv/identify.cpp @@ -42,9 +42,10 @@ class NSIdentifyRequestListener : public NickServ::IdentifyRequestListener } if (u->IsIdentified()) - Log(LOG_COMMAND, source, cmd) << "to log out of account " << u->Account()->GetDisplay(); + cmd->logger.Command(LogType::COMMAND, source, _("{source} used {command} to log out of account {0}"), u->Account()->GetDisplay()); + + cmd->logger.Command(LogType::COMMAND, source, _("{source} used {command} and identified for account {0}"), na->GetAccount()->GetDisplay()); - Log(LOG_COMMAND, source, cmd) << "and identified for account " << na->GetAccount()->GetDisplay(); source.Reply(_("Password accepted - you are now recognized as \002{0}\002."), na->GetAccount()->GetDisplay()); u->Identify(na); } @@ -55,14 +56,20 @@ class NSIdentifyRequestListener : public NickServ::IdentifyRequestListener return; bool accountexists = NickServ::FindNick(req->GetAccount()) != NULL; - Log(LOG_COMMAND, source, cmd) << "and failed to identify to" << (accountexists ? " " : " nonexistent ") << "account " << req->GetAccount(); + if (!accountexists) + cmd->logger.Command(LogType::COMMAND, source, _("{source} used {command} and failed to identify to nonexistent account {0}"), req->GetAccount()); + else + cmd->logger.Command(LogType::COMMAND, source, _("{source} used {command} and failed to identify to account {0}"), req->GetAccount()); + if (accountexists) { source.Reply(_("Password incorrect.")); source.GetUser()->BadPassword(); } else + { source.Reply("\002{0}\002 isn't registered.", req->GetAccount()); + } } }; diff --git a/modules/nickserv/info.cpp b/modules/nickserv/info.cpp index 0fd4169e9..eb9b103fa 100644 --- a/modules/nickserv/info.cpp +++ b/modules/nickserv/info.cpp @@ -194,13 +194,19 @@ class CommandNSSetHide : public Command if (arg.equals_ci("ON")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change hide " << param.upper() << " to " << arg.upper() << " for " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, + _("{source} used {command} to change hide {0} to {1} for {2}"), + param.upper(), arg.upper(), nc->GetDisplay()); + nc->SetS<bool>(flag, true); source.Reply(onmsg, nc->GetDisplay(), source.service->nick); } else if (arg.equals_ci("OFF")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change hide " << param.upper() << " to " << arg.upper() << " for " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, + _("{source} used {command} to change hide {0} to {1} for {2}"), + param.upper(), arg.upper(), nc->GetDisplay()); + nc->UnsetS<bool>(flag); source.Reply(offmsg, nc->GetDisplay(), source.service->nick); } diff --git a/modules/nickserv/list.cpp b/modules/nickserv/list.cpp index 735df7d7d..e8d340683 100644 --- a/modules/nickserv/list.cpp +++ b/modules/nickserv/list.cpp @@ -213,13 +213,17 @@ class CommandNSSetPrivate : public Command if (param.equals_ci("ON")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable private for " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, + _("{source} used {command} to enable private for {0}"), nc->GetDisplay()); + nc->SetPrivate(true); source.Reply(_("Private option is now \002on\002 for \002{0}\002."), nc->GetDisplay()); } else if (param.equals_ci("OFF")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable private for " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, + _("{source} used {command} to disable private for {0}"), nc->GetDisplay()); + nc->SetPrivate(true); source.Reply(_("Private option is now \002off\002 for \002{0}\002."), nc->GetDisplay()); } diff --git a/modules/nickserv/logout.cpp b/modules/nickserv/logout.cpp index 0e6cdb46a..3cff5e9e8 100644 --- a/modules/nickserv/logout.cpp +++ b/modules/nickserv/logout.cpp @@ -61,7 +61,9 @@ class CommandNSLogout : public Command #endif u2->super_admin = false; /* Dont let people logout and remain a SuperAdmin */ - Log(LOG_COMMAND, source, this) << "to logout " << u2->nick; + + // XXX show account name here? + logger.Command(LogType::COMMAND, source, _("{source} used {command} to logout {0}"), u2->nick); if (!nick.empty()) source.Reply(_("\002{0}\002 has been logged out."), nick); diff --git a/modules/nickserv/main/account.cpp b/modules/nickserv/main/account.cpp index a6fa19adf..86c96b14f 100644 --- a/modules/nickserv/main/account.cpp +++ b/modules/nickserv/main/account.cpp @@ -283,7 +283,7 @@ void AccountImpl::SetDisplay(NickServ::Nick *na) NickServ::Account* &nc = map[this->GetDisplay()]; if (nc) - Log(LOG_DEBUG) << "Duplicate account " << this->GetDisplay() << " in nickcore table?"; + Anope::Logger.Debug("Duplicate account {0} in nickcore table?", this->GetDisplay()); nc = this; } diff --git a/modules/nickserv/main/nickserv.cpp b/modules/nickserv/main/nickserv.cpp index 3741d119b..3921534c9 100644 --- a/modules/nickserv/main/nickserv.cpp +++ b/modules/nickserv/main/nickserv.cpp @@ -426,7 +426,7 @@ class NickServCore : public Module, public NickServ::NickServService void OnDelCore(NickServ::Account *nc) override { - Log(NickServ, "nick") << "Deleting nickname group " << nc->GetDisplay(); + NickServ->logger.Category("nick").Log(_("Deleting nickname group {0}"), nc->GetDisplay()); /* Clean up this nick core from any users online */ for (unsigned int i = nc->users.size(); i > 0; --i) @@ -441,7 +441,7 @@ class NickServCore : public Module, public NickServ::NickServService void OnChangeCoreDisplay(NickServ::Account *nc, const Anope::string &newdisplay) override { - Log(LOG_NORMAL, "nick", NickServ) << "Changing " << nc->GetDisplay() << " nickname group display to " << newdisplay; + Anope::Logger.Bot(NickServ).Category("nick").Log(_("Changing {0} nickname group display to {1}"), nc->GetDisplay(), newdisplay); } void OnNickIdentify(User *u) override @@ -555,7 +555,7 @@ class NickServCore : public Module, public NickServ::NickServService IRCD->Send<messages::Login>(u, na); if (!Config->GetModule("nickserv/main")->Get<bool>("nonicknameownership") && na->GetAccount() == u->Account() && !na->GetAccount()->IsUnconfirmed()) u->SetMode(NickServ, "REGISTERED"); - Log(u, "", NickServ) << u->GetMask() << " automatically identified for group " << u->Account()->GetDisplay(); + u->logger.Bot(NickServ).Log(_("{0} automatically identified for account {1}"), u->GetMask(), u->Account()->GetDisplay()); } if (!u->nick.equals_ci(oldnick) && old_na) @@ -655,9 +655,10 @@ class NickServCore : public Module, public NickServ::NickServService if (expire) { - Log(LOG_NORMAL, "nickserv/expire", NickServ) << "Expiring nickname " << na->GetNick() << " (group: " << na->GetAccount()->GetDisplay() << ") (e-mail: " << (na->GetAccount()->GetEmail().empty() ? "none" : na->GetAccount()->GetEmail()) << ")"; + Anope::Logger.Bot(NickServ).Category("nickserv/expire").Log(_("Expiring nickname {0} (account: {1}) (e-mail: {2})"), + na->GetNick(), na->GetAccount()->GetDisplay(), na->GetAccount()->GetEmail().empty() ? "none" : na->GetAccount()->GetEmail()); EventManager::Get()->Dispatch(&NickServ::Event::NickExpire::OnNickExpire, na); - delete na; + na->Delete(); } } } diff --git a/modules/nickserv/maxemail.cpp b/modules/nickserv/maxemail.cpp index 0660e7b92..b7924d2c2 100644 --- a/modules/nickserv/maxemail.cpp +++ b/modules/nickserv/maxemail.cpp @@ -39,7 +39,7 @@ class NSMaxEmail : public Module username = username.substr(0, sz); Anope::string cleaned = username + email.substr(host); - Log(LOG_DEBUG) << "cleaned " << email << " to " << cleaned; + logger.Debug("cleaned {0} to {1}", email, cleaned); return cleaned; } diff --git a/modules/nickserv/recover.cpp b/modules/nickserv/recover.cpp index 60a0bee2f..191e6e019 100644 --- a/modules/nickserv/recover.cpp +++ b/modules/nickserv/recover.cpp @@ -50,7 +50,7 @@ class NSRecoverRequestListener : public NickServ::IdentifyRequestListener if (!na) return; - Log(LOG_COMMAND, source, cmd) << "for " << na->GetNick(); + cmd->logger.Command(LogType::COMMAND, source, _("{source} used {command} for {0}"), na->GetNick()); /* Nick is being held by us, release it */ if (na->HasFieldS("HELD")) @@ -69,7 +69,7 @@ class NSRecoverRequestListener : public NickServ::IdentifyRequestListener if (!source.GetAccount() && na->GetAccount()->IsSecure()) { source.GetUser()->Login(u->Account()); - Log(LOG_COMMAND, source, cmd) << "and was automatically identified to " << u->Account()->GetDisplay(); + cmd->logger.Command(LogType::COMMAND, source, _("{source} used {command} and was automatically identified to {0}"), u->Account()->GetDisplay()); } if (Config->GetModule("nickserv/recover")->Get<bool>("restoreonrecover")) @@ -100,7 +100,7 @@ class NSRecoverRequestListener : public NickServ::IdentifyRequestListener if (!source.GetAccount() && na->GetAccount()->IsSecure()) { source.GetUser()->Login(na->GetAccount()); // Identify the user using the command if they arent identified - Log(LOG_COMMAND, source, cmd) << "and was automatically identified to " << na->GetNick() << " (" << na->GetAccount()->GetDisplay() << ")"; + cmd->logger.Command(LogType::COMMAND, source, _("{source} used {command} and was automatically identified to {0} ({1})"), na->GetNick(), na->GetAccount()->GetDisplay()); source.Reply(_("You have been logged in as \002{0}\002."), na->GetAccount()->GetDisplay()); } @@ -139,7 +139,7 @@ class NSRecoverRequestListener : public NickServ::IdentifyRequestListener source.Reply(_("Access denied.")); if (!pass.empty()) { - Log(LOG_COMMAND, source, cmd) << "with an invalid password for " << user; + cmd->logger.Command(LogType::COMMAND, source, _("{source} used {command} with an invalid password for {0}"), user); if (source.GetUser()) source.GetUser()->BadPassword(); } diff --git a/modules/nickserv/register.cpp b/modules/nickserv/register.cpp index b06e08075..1554c0033 100644 --- a/modules/nickserv/register.cpp +++ b/modules/nickserv/register.cpp @@ -53,7 +53,7 @@ class CommandNSConfirm : public Command na->GetAccount()->SetUnconfirmed(false); EventManager::Get()->Dispatch(&NickServ::Event::NickConfirm::OnNickConfirm, source.GetUser(), na->GetAccount()); - Log(LOG_ADMIN, source, this) << "to confirm nick " << na->GetNick() << " (" << na->GetAccount()->GetDisplay() << ")"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to confirm nickname {0} ({1})"), na->GetNick(), na->GetAccount()->GetDisplay()); source.Reply(_("\002{0}\002 has been confirmed."), na->GetNick()); /* Login the users online already */ @@ -79,7 +79,7 @@ class CommandNSConfirm : public Command NickServ::Account *nc = source.nc; nc->Shrink<Anope::string>("passcode"); - Log(LOG_COMMAND, source, this) << "to confirm their email"; + logger.Command(LogType::COMMAND, source, _("{source} used {command} to confirm their email"), source.nc->GetEmail()); source.Reply(_("Your email address of \002{0}\002 has been confirmed."), source.nc->GetEmail()); nc->SetUnconfirmed(false); @@ -257,7 +257,8 @@ class CommandNSRegister : public Command na->SetLastRealname(source.GetNick()); } - Log(LOG_COMMAND, source, this) << "to register " << na->GetNick() << " (email: " << (!na->GetAccount()->GetEmail().empty() ? na->GetAccount()->GetEmail() : "none") << ")"; + logger.Command(LogType::COMMAND, source, _("{source} used {command} to register {0} (email: {1})"), + na->GetNick(), !na->GetAccount()->GetEmail().empty() ? na->GetAccount()->GetEmail() : "none"); source.Reply(_("\002{0}\002 has been registered."), u_nick); @@ -346,13 +347,13 @@ class CommandNSResend : public Command if (!SendRegmail(source.GetUser(), na, source.service)) { - Log(this->GetOwner()) << "Unable to resend registration verification code for " << source.GetNick(); + logger.Log("Unable to resend registration verificiation code for {0}", source.GetNick()); return; } na->GetAccount()->lastmail = Anope::CurTime; source.Reply(_("Your passcode has been re-sent to \002{0}\002."), na->GetAccount()->GetEmail()); - Log(LOG_COMMAND, source, this) << "to resend registration verification code"; + logger.Command(LogType::COMMAND, source, _("{source} used {command} to resend registration verification code")); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/nickserv/resetpass.cpp b/modules/nickserv/resetpass.cpp index 2a3a8c418..5361ed091 100644 --- a/modules/nickserv/resetpass.cpp +++ b/modules/nickserv/resetpass.cpp @@ -49,7 +49,8 @@ class CommandNSResetPass : public Command if (SendResetEmail(source.GetUser(), na, source.service)) { - Log(LOG_COMMAND, source, this) << "for " << na->GetNick() << " (group: " << na->GetAccount()->GetDisplay() << ")"; + logger.Command(LogType::COMMAND, source, _("{source} used {command} for {0} (account: {1})"), na->GetNick(), na->GetAccount()->GetDisplay()); + source.Reply(_("Password reset email for \002{0}\002 has been sent."), na->GetNick()); } } @@ -109,7 +110,7 @@ class NSResetPass : public Module reset.Unset(nc); nc->SetUnconfirmed(false); - Log(LOG_COMMAND, source, &commandnsresetpass) << "confirmed RESETPASS to forcefully identify as " << na->GetNick(); + command->logger.Command(LogType::COMMAND, source, _("{source} used {command} and confirmed password reset to forcefully identify as {0}"), na->GetNick()); if (source.GetUser()) { diff --git a/modules/nickserv/set.cpp b/modules/nickserv/set.cpp index c7d03f8d2..df6696fbf 100644 --- a/modules/nickserv/set.cpp +++ b/modules/nickserv/set.cpp @@ -155,7 +155,7 @@ class CommandNSSetPassword : public Command return; } - Log(LOG_COMMAND, source, this) << "to change their password"; + logger.Command(LogType::COMMAND, source, _("{source} used {command} to change their password")); Anope::string tmp_pass; Anope::Encrypt(param, tmp_pass); @@ -216,7 +216,7 @@ class CommandNSSASetPassword : public Command return; } - Log(LOG_ADMIN, source, this) << "to change the password of " << nc->GetDisplay(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to change the password of {0}"), nc->GetDisplay()); Anope::string tmp_pass; Anope::Encrypt(params[1], tmp_pass); @@ -263,13 +263,13 @@ class CommandNSSetAutoOp : public Command if (param.equals_ci("ON")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable autoop for " << na->GetAccount()->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to enable autoop for {0}"), na->GetAccount()->GetDisplay()); nc->SetAutoOp(true); source.Reply(_("Services will from now on set status modes on \002{0}\002 in channels."), nc->GetDisplay()); } else if (param.equals_ci("OFF")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable autoop for " << na->GetAccount()->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to disable autoop for {0}"), na->GetAccount()->GetDisplay()); nc->SetAutoOp(false); source.Reply(_("Services will no longer set status modes on \002{0}\002 in channels."), nc->GetDisplay()); } @@ -356,7 +356,9 @@ class CommandNSSetDisplay : public Command if (MOD_RESULT == EVENT_STOP) return; - Log(user_na->GetAccount() == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the display of " << user_na->GetAccount()->GetDisplay() << " to " << na->GetNick(); + logger.Command(user_na->GetAccount() == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, + _("{source} used {command} to change the display of {0} to {1}"), + user_na->GetAccount()->GetDisplay(), na->GetNick()); user_na->GetAccount()->SetDisplay(na); @@ -483,7 +485,7 @@ class CommandNSSetEmail : public Command if (param.empty()) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to unset the email of " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to unset the email of {0}"), nc->GetDisplay()); nc->SetEmail(""); source.Reply(_("E-mail address for \002{0}\002 unset."), nc->GetDisplay()); } @@ -494,7 +496,8 @@ class CommandNSSetEmail : public Command } else { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the email of " << nc->GetDisplay() << " to " << param; + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to change the email of {0} to {1}"), + nc->GetDisplay(), param); nc->SetEmail(param); source.Reply(_("E-mail address for \002{0}\002 changed to \002{1}\002."), nc->GetDisplay(), param); } @@ -565,13 +568,13 @@ class CommandNSSetKeepModes : public Command if (param.equals_ci("ON")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable keepmodes for " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to enable keepmodes for {0}"), nc->GetDisplay()); nc->SetKeepModes(true); source.Reply(_("Keep modes for \002{0}\002 is now \002on\002."), nc->GetDisplay()); } else if (param.equals_ci("OFF")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable keepmodes for " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to disable keepmodes for {2}"), nc->GetDisplay()); nc->SetKeepModes(false); source.Reply(_("Keep modes for \002{0}\002 is now \002off\002."), nc->GetDisplay()); } @@ -655,7 +658,10 @@ class CommandNSSetKill : public Command nc->SetKillProtect(true); nc->SetKillQuick(false); nc->SetKillImmed(false); - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to set kill on for " << nc->GetDisplay(); + + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to set kill to {0} for {1}"), + "ON", nc->GetDisplay()); + source.Reply(_("Protection is now \002on\002 for \002{0}\002."), nc->GetDisplay()); } else if (param.equals_ci("QUICK")) @@ -663,7 +669,10 @@ class CommandNSSetKill : public Command nc->SetKillProtect(true); nc->SetKillQuick(true); nc->SetKillImmed(false); - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to set kill quick for " << nc->GetDisplay(); + + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to set kill to {0} for {1}"), + "QUICK", nc->GetDisplay()); + source.Reply(_("Protection is now \002on\002 for \002{0}\002, with a reduced delay."), nc->GetDisplay()); } else if (param.equals_ci("IMMED")) @@ -673,7 +682,10 @@ class CommandNSSetKill : public Command nc->SetKillProtect(true); nc->SetKillQuick(false); nc->SetKillImmed(true); - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to set kill immed for " << nc->GetDisplay(); + + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to set kill to {0} for {1}"), + "IMMED", nc->GetDisplay()); + source.Reply(_("Protection is now \002on\002 for \002{0}\002, with no delay."), nc->GetDisplay()); } else @@ -684,7 +696,9 @@ class CommandNSSetKill : public Command nc->SetKillProtect(true); nc->SetKillQuick(false); nc->SetKillImmed(false); - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable kill for " << nc->GetDisplay(); + + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to disable kill for {0}"), nc->GetDisplay()); + source.Reply(_("Protection is now \002off\002 for \002{0}\002."), nc->GetDisplay()); } else @@ -778,7 +792,8 @@ class CommandNSSetLanguage : public Command } } - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change the language of " << nc->GetDisplay() << " to " << param; + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to change the language of {0} to {1}"), + nc->GetDisplay(), param); nc->SetLanguage(param); @@ -877,13 +892,17 @@ class CommandNSSetMessage : public Command if (param.equals_ci("ON")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable " << source.command << " for " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to enable {0} for {1}"), + "MSG", nc->GetDisplay()); + nc->SetMsg(true); source.Reply(_("Services will now reply to \002{0}\002 with \002messages\002."), nc->GetDisplay()); } else if (param.equals_ci("OFF")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable " << source.command << " for " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to disable {0} for {1}"), + "MSG", nc->GetDisplay()); + nc->SetMsg(false); source.Reply(_("Services will now reply to \002{0}\002 with \002notices\002."), nc->GetDisplay()); } @@ -974,13 +993,15 @@ class CommandNSSetSecure : public Command if (param.equals_ci("ON")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to enable secure for " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to enable {0} for {1}"), + "SECURE", nc->GetDisplay()); nc->SetSecure(true); source.Reply(_("Secure option is now \002on\002 for \002{0}\002."), nc->GetDisplay()); } else if (param.equals_ci("OFF")) { - Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to disable secure for " << nc->GetDisplay(); + logger.Command(nc == source.GetAccount() ? LogType::COMMAND : LogType::ADMIN, source, _("{source} used {command} to disable {0} for {1}"), + "SECURE", nc->GetDisplay()); nc->SetSecure(false); source.Reply(_("Secure option is now \002off\002 for \002{0}\002."), nc->GetDisplay()); } @@ -1058,13 +1079,17 @@ class CommandNSSASetNoexpire : public Command if (param.equals_ci("ON")) { - Log(LOG_ADMIN, source, this) << "to enable noexpire for " << na->GetAccount()->GetDisplay(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to enable {0} for {1}"), + "NOEXPIRE", na->GetAccount()->GetDisplay()); + na->SetNoExpire(true); source.Reply(_("\002{0}\002 \002will not\002 expire."), na->GetNick()); } else if (param.equals_ci("OFF")) { - Log(LOG_ADMIN, source, this) << "to disable noexpire for " << na->GetAccount()->GetDisplay(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to disable {0} for {1}"), + "NOEXPIRE", na->GetAccount()->GetDisplay()); + na->SetNoExpire(false); source.Reply(_("\002{0}\002 \002will\002 expire."), na->GetNick()); } @@ -1174,7 +1199,7 @@ class NSSet : public Module if (params[0] == n->second) { uac->SetEmail(n->first); - Log(LOG_COMMAND, source, command) << "to confirm their email address change to " << uac->GetEmail(); + command->logger.Command(LogType::COMMAND, source, _("{source} used {command} to confirm their email address change to {0}"), uac->GetEmail()); source.Reply(_("Your email address has been changed to \002%s\002."), uac->GetEmail().c_str()); ns_set_email.Unset(uac); return EVENT_STOP; diff --git a/modules/nickserv/suspend.cpp b/modules/nickserv/suspend.cpp index 90362bcf2..c630dcd92 100644 --- a/modules/nickserv/suspend.cpp +++ b/modules/nickserv/suspend.cpp @@ -194,7 +194,8 @@ class CommandNSSuspend : public Command } } - Log(LOG_ADMIN, source, this) << "for " << nick << " (" << (!reason.empty() ? reason : "No reason") << "), expires on " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); + logger.Command(LogType::ADMIN, source, _("{source} used {command} for {0} ({1}), expires on {2}"), + nick, !reason.empty() ? reason : "No reason", expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); source.Reply(_("\002{0}\002 is now suspended."), na->GetNick()); EventManager::Get()->Dispatch(&Event::NickSuspend::OnNickSuspend, na); @@ -202,8 +203,9 @@ class CommandNSSuspend : public Command bool OnHelp(CommandSource &source, const Anope::string &subcommand) override { +#warning "show expiry" source.Reply(_("Suspends \037account\037, which prevents it from being used while keeping all the data for it." - " If an expiry is given the account will be unsuspended after that period of time, otherwise the default expiry from the configuration is used.")); // XXX + " If an expiry is given the account will be unsuspended after that period of time, otherwise the default expiry from the configuration is used.")); return true; } }; @@ -238,7 +240,8 @@ class CommandNSUnSuspend : public Command return; } - Log(LOG_ADMIN, source, this) << "for " << na->GetNick() << " which was suspended by " << (!si->GetBy().empty() ? si->GetBy() : "(none)") << " for: " << (!si->GetReason().empty() ? si->GetReason() : "No reason"); + logger.Command(LogType::ADMIN, source, _("{source} used {command} for {0}, which was suspended by {1} for: {2}"), + !si->GetBy().empty() ? si->GetBy() : "(noone)", !si->GetReason().empty() ? si->GetReason() : "no reason"); si->Delete(); @@ -329,7 +332,7 @@ class NSSuspend : public Module na->SetLastSeen(Anope::CurTime); s->Delete(); - Log(LOG_NORMAL, "nickserv/expire", Config->GetClient("NickServ")) << "Expiring suspend for " << na->GetNick(); + logger.Category("nickserv/expire").Bot("NickServ").Log(_("Expiring suspend for {0}"), na->GetNick()); } } diff --git a/modules/operserv/akill.cpp b/modules/operserv/akill.cpp index 9c4a53d23..10a87db2b 100644 --- a/modules/operserv/akill.cpp +++ b/modules/operserv/akill.cpp @@ -147,11 +147,12 @@ class CommandOSAKill : public Command ++affected; float percent = static_cast<float>(affected) / static_cast<float>(UserListByNick.size()) * 100.0; - if (percent > 95) + if (percent > 95) // XXX make this configurable.. { source.Reply(_("\002{0}\002 coverage is too wide; Please use a more specific mask."), mask); - Log(LOG_ADMIN, source, this) << "tried to akill " << percent << "% of the network (" << affected << " users)"; - delete x; + logger.Command(LogType::ADMIN, source, _("{source} used {command} and tried to akill {0}% of the network ({1} users)"), + 95, affected); + x->Delete(); return; } @@ -159,7 +160,7 @@ class CommandOSAKill : public Command MOD_RESULT = EventManager::Get()->Dispatch(&Event::AddXLine::OnAddXLine, source, x, akills); if (MOD_RESULT == EVENT_STOP) { - delete x; + x->Delete(); return; } @@ -169,7 +170,8 @@ class CommandOSAKill : public Command source.Reply(_("\002{0}\002 added to the akill list."), mask); - Log(LOG_ADMIN, source, this) << "on " << mask << " (" << x->GetReason() << "), expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} ({1}), expires in {2} [affects {3} user(s) ({4}%)]"), + mask, x->GetReason(), expires ? Anope::Duration(expires - Anope::CurTime) : "never", affected, percent); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); } @@ -202,7 +204,7 @@ class CommandOSAKill : public Command if (!x) return; - Log(LOG_ADMIN, source, this) << "to remove " << x->GetMask() << " from the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove {0} from the akill list"), x->GetMask()); ++deleted; x->Delete(); @@ -231,7 +233,8 @@ class CommandOSAKill : public Command { EventManager::Get()->Dispatch(&Event::DelXLine::OnDelXLine, source, x, akills); - Log(LOG_ADMIN, source, this) << "to remove " << x->GetMask() << " from the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove {0} from the akill list"), x->GetMask()); + source.Reply(_("\002{0}\002 deleted from the akill list."), x->GetMask()); x->Delete(); } @@ -345,7 +348,8 @@ class CommandOSAKill : public Command x->Delete(); } - Log(LOG_ADMIN, source, this) << "to CLEAR the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to CLEAR the akill list")); + source.Reply(_("The akill list has been cleared.")); if (Anope::ReadOnly) diff --git a/modules/operserv/chankill.cpp b/modules/operserv/chankill.cpp index 674200c84..32079f61d 100644 --- a/modules/operserv/chankill.cpp +++ b/modules/operserv/chankill.cpp @@ -109,7 +109,7 @@ class CommandOSChanKill : public Command akills->OnMatch(uc->user, x); } - Log(LOG_ADMIN, source, this) << "on " << c->name << " (" << realreason << ")"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to {0} ({1})"), c->name, realreason); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/operserv/config.cpp b/modules/operserv/config.cpp index 33ef0acef..2b6ce015d 100644 --- a/modules/operserv/config.cpp +++ b/modules/operserv/config.cpp @@ -52,7 +52,8 @@ class CommandOSConfig : public Command block->Set(params[2], params[3]); - Log(LOG_ADMIN, source, this) << "to change the configuration value of " << params[1] << ":" << params[2] << " to " << params[3]; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to change the configuration value of {0}:{1} to {2}"), + params[1], params[2], params[3]); source.Reply(_("Value of \002{0}:{1}\002 changed to \002{2}\002."), params[1], params[2], params[3]); } else if (what.equals_ci("VIEW")) @@ -60,7 +61,7 @@ class CommandOSConfig : public Command /* Blocks we should show */ const Anope::string show_blocks[] = { "serverinfo", "networkinfo", "options", "" }; - Log(LOG_ADMIN, source, this) << "VIEW"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to view the configuration")); for (unsigned i = 0; !show_blocks[i].empty(); ++i) { diff --git a/modules/operserv/defcon.cpp b/modules/operserv/defcon.cpp index e6839a3e8..3f24b2b63 100644 --- a/modules/operserv/defcon.cpp +++ b/modules/operserv/defcon.cpp @@ -108,7 +108,7 @@ struct DefconConfig static DefconConfig DConfig; -static void runDefCon(); +static void runDefCon(Module *module); static Anope::string defconReverseModes(const Anope::string &modes); static Timer *timeout; @@ -135,7 +135,8 @@ class DefConTimeout : public Timer { DConfig.defaultlevel = level; EventManager::Get()->Dispatch(&Event::DefconLevel::OnDefconLevel, level); - Log(Config->GetClient("OperServ"), "operserv/defcon") << "Defcon level timeout, returning to level " << level; + + this->GetOwner()->logger.Bot("OperServ").Category("operserv/defcon").Log(_("Defcon level timeout, returning to level {0}"), level); if (DConfig.globalondefcon && global) { @@ -148,7 +149,7 @@ class DefConTimeout : public Timer global->SendGlobal(NULL, "", DConfig.message); } - runDefCon(); + runDefCon(this->GetOwner()); } } }; @@ -223,7 +224,8 @@ class CommandOSDefcon : public Command source.Reply(_("Services are now at defcon \002{0}\002."), DConfig.defaultlevel); this->SendLevels(source); - Log(LOG_ADMIN, source, this) << "to change defcon level to " << newLevel; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to change defcon level to {0}"), newLevel); /* Global notice the user what is happening. Also any Message that the Admin would like to add. Set in config file. */ @@ -240,7 +242,7 @@ class CommandOSDefcon : public Command } /* Run any defcon functions, e.g. FORCE CHAN MODE */ - runDefCon(); + runDefCon(this->GetOwner()); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -299,7 +301,7 @@ class OSDefcon : public Module { if (cm->type == MODE_STATUS || cm->type == MODE_LIST) { - Log(this) << "DefConChanModes mode character '" << mode << "' cannot be locked"; + logger.Log("DefConChanModes mode character '{0}' cannot be locked", mode); continue; } else if (add) @@ -313,7 +315,7 @@ class OSDefcon : public Module if (!ss.GetToken(param)) { - Log(this) << "DefConChanModes mode character '" << mode << "' has no parameter while one is expected"; + logger.Log("DefConChanModes mode character '{0]' has no parameter while one is expected", mode); continue; } @@ -338,7 +340,7 @@ class OSDefcon : public Module { DConfig.DefConModesOn.erase("REDIRECT"); - Log(this) << "DefConChanModes must lock mode +l as well to lock mode +L"; + logger.Log("DefConChanModes must lock mode +l as well to lock mode +L"); } } @@ -517,7 +519,7 @@ class OSDefcon : public Module ServiceBot *OperServ = Config->GetClient("OperServ"); if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills) { - Log(OperServ, "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; + logger.Bot(OperServ).Category("operserv/defcon").Log("Adding akill for *@{0}", u->host); #warning "xline allocated on stack" #if 0 XLine x("*@" + u->host, OperServ ? OperServ->nick : "defcon", Anope::CurTime + DConfig.akillexpire, DConfig.akillreason, XLineManager::GenerateUID()); @@ -580,7 +582,7 @@ class OSDefcon : public Module } }; -static void runDefCon() +static void runDefCon(Module *module) { ServiceBot *OperServ = Config->GetClient("OperServ"); if (DConfig.Check(DEFCON_FORCE_CHAN_MODES)) @@ -589,7 +591,7 @@ static void runDefCon() { if (DConfig.chanmodes[0] == '+' || DConfig.chanmodes[0] == '-') { - Log(OperServ, "operserv/defcon") << "DEFCON: setting " << DConfig.chanmodes << " on all channels"; + module->logger.Bot(OperServ).Category("operserv/defcon").Log(_("Setting {0} on all channels"), DConfig.chanmodes); DefConModesSet = true; for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) it->second->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str()); @@ -606,7 +608,7 @@ static void runDefCon() Anope::string newmodes = defconReverseModes(DConfig.chanmodes); if (!newmodes.empty()) { - Log(OperServ, "operserv/defcon") << "DEFCON: setting " << newmodes << " on all channels"; + module->logger.Bot(OperServ).Category("operserv/defcon").Log(_("SSetting {0} on all channels"), newmodes); for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) it->second->SetModes(OperServ, true, "%s", newmodes.c_str()); } diff --git a/modules/operserv/dns.cpp b/modules/operserv/dns.cpp index 1ccb54530..8efa94fa9 100644 --- a/modules/operserv/dns.cpp +++ b/modules/operserv/dns.cpp @@ -383,7 +383,7 @@ class CommandOSDNS : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to add zone " << zone; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add zone {0}"), zone); DNSZone *z = Serialize::New<DNSZone *>(); z->SetName(zone); @@ -404,7 +404,7 @@ class CommandOSDNS : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to delete zone " << z->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to delete zone {0}"), z->GetName()); for (DNSZoneMembership *mem : z->GetRefs<DNSZoneMembership *>()) mem->Delete(); @@ -459,7 +459,7 @@ class CommandOSDNS : public Command manager->Notify(zone); } - Log(LOG_ADMIN, source, this) << "to add server " << s->GetName() << " to zone " << z->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add server {0} to zone {1}"), s->GetName(), z->GetName()); source.Reply(_("Server \002{0}\002 added to zone \002{1}\002."), s->GetName(), z->GetName()); } @@ -481,7 +481,8 @@ class CommandOSDNS : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to add server " << s->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add server {2}"), s->GetName()); + source.Reply(_("Added server \002{0}\002."), s->GetName()); } else @@ -497,7 +498,7 @@ class CommandOSDNS : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to add server " << s->GetName() << " to zone " << zone; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add server {0} to zone {1}"), s->GetName(), z->GetName()); DNSZoneMembership *mem = Serialize::New<DNSZoneMembership *>(); mem->SetServer(s); @@ -541,7 +542,7 @@ class CommandOSDNS : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to remove server " << s->GetName() << " from zone " << z->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove server {0} to zone {1}"), s->GetName(), z->GetName()); if (manager) { @@ -569,7 +570,8 @@ class CommandOSDNS : public Command if (manager) manager->UpdateSerial(); - Log(LOG_ADMIN, source, this) << "to delete server " << s->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to delete server {0}"), s->GetName()); + source.Reply(_("Removed server \002{0}\002."), s->GetName()); s->Delete(); } @@ -606,7 +608,8 @@ class CommandOSDNS : public Command ip->SetIP(params[2]); source.Reply(_("Added IP \002{0}\002 to \002{1}\002."), params[2], s->GetName()); - Log(LOG_ADMIN, source, this) << "to add IP " << params[2] << " to " << s->GetName(); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add IP {0} to {1}"), params[2], s->GetName()); if (s->Active() && manager) { @@ -635,7 +638,8 @@ class CommandOSDNS : public Command ip->Delete(); source.Reply(_("Removed IP \002{0}\002 from \002{1}\002."), params[2], s->GetName()); - Log(LOG_ADMIN, source, this) << "to remove IP " << params[2] << " from " << s->GetName(); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add IP {0} to {1}"), params[2], s->GetName()); if (s->GetRefs<DNSIP *>().empty()) { @@ -725,7 +729,8 @@ class CommandOSDNS : public Command s->SetActive(true); source.Reply(_("Pooled \002{0}\002."), s->GetName()); - Log(LOG_ADMIN, source, this) << "to pool " << s->GetName(); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to pool {0}"), s->GetName()); } @@ -751,7 +756,8 @@ class CommandOSDNS : public Command s->SetPool(false); source.Reply(_("Depooled \002{0}\002."), s->GetName()); - Log(LOG_ADMIN, source, this) << "to depool " << s->GetName(); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to depool {0}"), s->GetName()); } public: @@ -882,7 +888,7 @@ class ModuleDNS : public Module if (dns && dns->GetPooled() && !dns->Active() && !dns->GetRefs<DNSIP *>().empty()) { dns->SetActive(true); - Log(this) << "Pooling server " << s->GetName(); + logger.Log(_("Pooling server {0}"), s->GetName()); } } } @@ -896,7 +902,7 @@ class ModuleDNS : public Module dns->SetActive(false); // Will be reactivated when it comes back else dns->SetPool(false); // Otherwise permanently pull this - Log(this) << "Depooling delinked server " << s->GetName(); + logger.Log(_("Depooling delinked server {0}"), s->GetName()); } } @@ -908,7 +914,7 @@ class ModuleDNS : public Module /* Check for user limit reached */ if (s && s->GetPooled() && s->Active() && s->GetLimit() && u->server->users >= s->GetLimit()) { - Log(this) << "Depooling full server " << s->GetName() << ": " << u->server->users << " users"; + logger.Log(_("Depooling full server {0}: {1} users"), s->GetName(), u->server->users); s->SetActive(false); } } @@ -925,7 +931,7 @@ class ModuleDNS : public Module /* Check for dropping under userlimit */ if (s->GetLimit() && !s->Active() && s->GetLimit() > u->server->users) { - Log(this) << "Pooling server " << s->GetName(); + logger.Log(_("Pooling server {0}"), s->GetName()); s->SetActive(true); } @@ -943,7 +949,7 @@ class ModuleDNS : public Module /* Check for very fast user drops */ if (s->Active() && diff <= this->user_drop_time) { - Log(this) << "Depooling server " << s->GetName() << ": dropped " << this->user_drop_mark << " users in " << diff << " seconds"; + logger.Log(_("Depooling server {0}: dropped {1} users in {2} seconds"), s->GetName(), this->user_drop_mark, diff); s->repool = Anope::CurTime + this->user_drop_readd_time; s->SetActive(false); } @@ -952,7 +958,7 @@ class ModuleDNS : public Module { s->SetActive(true); s->repool = 0; - Log(this) << "Pooling server " << s->GetName(); + logger.Log(_("Pooling server {0}"), s->GetName()); } } } @@ -1020,7 +1026,7 @@ class ModuleDNS : public Module if (last_warn + 60 < Anope::CurTime) { last_warn = Anope::CurTime; - Log(this) << "Warning! There are no pooled servers!"; + logger.Log("Warning! There are no pooled servers!"); } /* Something messed up, just return them all and hope one is available */ @@ -1040,7 +1046,7 @@ class ModuleDNS : public Module if (packet->answers.size() == answer_size) { - Log(this) << "Error! There are no servers with any IPs of type " << q.type; + logger.Log("Error! There are no servers with any IPs of type {0}", q.type); /* Send back an empty answer anyway */ } } diff --git a/modules/operserv/forbid.cpp b/modules/operserv/forbid.cpp index bf38fc2ac..928aa2685 100644 --- a/modules/operserv/forbid.cpp +++ b/modules/operserv/forbid.cpp @@ -158,7 +158,7 @@ class MyForbidService : public ForbidService else if (d->GetType() == FT_EMAIL) ftype = "email"; - Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << d->GetMask() << " type " << ftype; + this->GetOwner()->logger.Bot("OperServ").Category("expire/forbid").Log(_("Expiring forbid for {0} type {1}"), d->GetMask(), ftype); d->Delete(); } return Serialize::GetObjects<ForbidData *>(); @@ -270,7 +270,8 @@ class CommandOSForbid : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to add a forbid on " << entry << " of type " << subcommand; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add a forbid on {0} of type {1}"), entry, subcommand); + source.Reply(_("Added a forbid on \002{0}\002 of type \002{1}\002 to expire on \002{2}\002."), entry, subcommand.lower(), expiryt ? Anope::strftime(expiryt, source.GetAccount()) : "never"); /* apply forbid */ @@ -381,7 +382,8 @@ class CommandOSForbid : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to remove forbid on " << d->GetMask() << " of type " << subcommand; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove forbid on {0} of type {1}"), d->GetMask(), subcommand); + source.Reply(_("\002{0}\002 deleted from the \002{1}\002 forbid list."), d->GetMask(), subcommand); d->Delete(); } diff --git a/modules/operserv/ignore.cpp b/modules/operserv/ignore.cpp index 397916ca4..afdd36837 100644 --- a/modules/operserv/ignore.cpp +++ b/modules/operserv/ignore.cpp @@ -155,7 +155,7 @@ class OSIgnoreService : public IgnoreService if (id->GetTime() && !Anope::NoExpire && id->GetTime() <= Anope::CurTime) { - Log(LOG_NORMAL, "expire/ignore", Config->GetClient("OperServ")) << "Expiring ignore entry " << id->GetMask(); + this->GetOwner()->logger.Bot("OperServ").Category("expire/ignore").Log(_("Expiring ignore for {0}"), id->GetMask()); id->Delete(); } else @@ -244,12 +244,14 @@ class CommandOSIgnore : public Command if (!t) { source.Reply(_("\002{0}\002 will now permanently be ignored."), mask); - Log(LOG_ADMIN, source, this) << "to add a permanent ignore for " << mask; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add a permanent ignore for {0}"), mask); } else { source.Reply(_("\002{0}\002 will now be ignored for \002{1}\002."), mask, Anope::Duration(t, source.GetAccount())); - Log(LOG_ADMIN, source, this) << "to add an ignore on " << mask << " for " << Anope::Duration(t); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add an ignore on {0} for {1}"), mask, Anope::Duration(t)); } } @@ -261,7 +263,7 @@ class CommandOSIgnore : public Command { if (id->GetTime() && !Anope::NoExpire && id->GetTime() <= Anope::CurTime) { - Log(LOG_NORMAL, "expire/ignore", Config->GetClient("OperServ")) << "Expiring ignore entry " << id->GetMask(); + this->GetOwner()->logger.Bot("OperServ").Category("expire/ignore").Log(_("Expiring ignore entry {0}"), id->GetMask()); id->Delete(); } } @@ -321,7 +323,8 @@ class CommandOSIgnore : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to remove an ignore on " << mask; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove an ignore on {0}"), mask); + source.Reply(_("\002{0}\002 will no longer be ignored."), mask); ign->Delete(); } @@ -334,7 +337,8 @@ class CommandOSIgnore : public Command for (Ignore *ign : Serialize::GetObjects<Ignore *>()) ign->Delete(); - Log(LOG_ADMIN, source, this) << "to CLEAR the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to CLEAR the ignore list")); + source.Reply(_("Ignore list has been cleared.")); } diff --git a/modules/operserv/info.cpp b/modules/operserv/info.cpp index c6038af5a..ff88a07d1 100644 --- a/modules/operserv/info.cpp +++ b/modules/operserv/info.cpp @@ -171,7 +171,8 @@ class CommandOSInfo : public Command o->SetCreated(Anope::CurTime); source.Reply(_("Added info to \002{0}\002."), target); - Log(LOG_ADMIN, source, this) << "to add information to " << target; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add oper information to {0}: {1}"), target, info); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); @@ -198,7 +199,8 @@ class CommandOSInfo : public Command o->Delete(); source.Reply(_("Deleted info from \002{0}\002."), target); - Log(LOG_ADMIN, source, this) << "to remove information from " << target; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove oper information from {0}: {1}"), target, info); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); @@ -222,7 +224,8 @@ class CommandOSInfo : public Command o->Delete(); source.Reply(_("Cleared info from \002{0}\002."), target); - Log(LOG_ADMIN, source, this) << "to clear information for " << target; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to clear oper information for {0}"), target); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); diff --git a/modules/operserv/jupe.cpp b/modules/operserv/jupe.cpp index 882effa4f..1d31ab1b4 100644 --- a/modules/operserv/jupe.cpp +++ b/modules/operserv/jupe.cpp @@ -42,7 +42,7 @@ class CommandOSJupe : public Command if (server == Me || server == Servers::GetUplink() || server->IsULined()) { - source.Reply(_("You can not jupe Servoces or its uplink server.")); + source.Reply(_("You can not jupe services, it's uplink, or any U:lined servers.")); return; } @@ -63,7 +63,7 @@ class CommandOSJupe : public Command Server *juped_server = new Server(Me, jserver, 1, rbuf, sid, true); IRCD->Send<messages::MessageServer>(juped_server); - Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} ({1}"), jserver, rbuf); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/operserv/kick.cpp b/modules/operserv/kick.cpp index 37e186156..ea9820dc2 100644 --- a/modules/operserv/kick.cpp +++ b/modules/operserv/kick.cpp @@ -60,7 +60,7 @@ class CommandOSKick : public Command return; } - Log(LOG_ADMIN, source, this) << "on " << u2->nick << " in " << c->name << " (" << s << ")"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} in {1} ({2})"), u2->nick, c->name, s); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/operserv/kill.cpp b/modules/operserv/kill.cpp index e4c97bcf4..42571bc10 100644 --- a/modules/operserv/kill.cpp +++ b/modules/operserv/kill.cpp @@ -50,7 +50,9 @@ class CommandOSKill : public Command reason = "No reason specified"; if (Config->GetModule("operserv/main")->Get<bool>("addakiller")) reason = "(" + source.GetNick() + ") " + reason; - Log(LOG_ADMIN, source, this) << "on " << u2->nick << " for " << reason; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} for {1}"), u2->nick, reason); + u2->Kill(*source.service, reason); } diff --git a/modules/operserv/list.cpp b/modules/operserv/list.cpp index 00b7bf746..e149c7e4b 100644 --- a/modules/operserv/list.cpp +++ b/modules/operserv/list.cpp @@ -36,9 +36,9 @@ class CommandOSChanList : public Command User *u2; if (!pattern.empty()) - Log(LOG_ADMIN, source, this) << "for " << pattern; + logger.Command(LogType::ADMIN, source, _("{source} used {command} for {0}"), pattern); else - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); if (!opt.empty() && opt.equals_ci("SECRET")) { @@ -138,9 +138,9 @@ class CommandOSUserList : public Command std::set<Anope::string> modes; if (!pattern.empty()) - Log(LOG_ADMIN, source, this) << "for " << pattern; + logger.Command(LogType::ADMIN, source, _("{source} used {command} for {0}"), pattern); else - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); if (!opt.empty() && opt.equals_ci("INVISIBLE")) modes.insert("INVIS"); diff --git a/modules/operserv/login.cpp b/modules/operserv/login.cpp index 270958875..f9dcdd38f 100644 --- a/modules/operserv/login.cpp +++ b/modules/operserv/login.cpp @@ -59,7 +59,8 @@ class CommandOSLogin : public Command return; } - Log(LOG_ADMIN, source, this) << "and successfully identified to " << source.service->nick; + logger.Command(LogType::ADMIN, source, _("{source} used {command} and successfully identified to {0}"), source.service->nick); + u->Extend<bool>("os_login", true); source.Reply(_("Password accepted.")); } @@ -106,7 +107,8 @@ class CommandOSLogout : public Command return; } - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); + u->Shrink<bool>("os_login"); source.Reply(_("You have been logged out.")); } diff --git a/modules/operserv/logsearch.cpp b/modules/operserv/logsearch.cpp index d9dc7b891..702abe0e0 100644 --- a/modules/operserv/logsearch.cpp +++ b/modules/operserv/logsearch.cpp @@ -95,14 +95,16 @@ class CommandOSLogSearch : public Command for (; i < params.size(); ++i) search_string += " " + params[i]; - Log(LOG_ADMIN, source, this) << "for " << search_string; + logger.Command(LogType::ADMIN, source, _("{source} used {command} for {2}"), search_string); const Anope::string &logfile_name = Config->GetModule(this->GetOwner())->Get<Anope::string>("logname"); std::list<Anope::string> matches; for (int d = days - 1; d >= 0; --d) { Anope::string lf_name = CreateLogName(logfile_name, Anope::CurTime - (d * 86400)); - Log(LOG_DEBUG) << "Searching " << lf_name; + + this->logger.Debug("Searching {0}", lf_name); + std::fstream fd(lf_name.c_str(), std::ios_base::in); if (!fd.is_open()) continue; diff --git a/modules/operserv/main/operserv.cpp b/modules/operserv/main/operserv.cpp index fc8dbf423..93c106497 100644 --- a/modules/operserv/main/operserv.cpp +++ b/modules/operserv/main/operserv.cpp @@ -33,7 +33,8 @@ class SGLineManager : public XLineManager void OnExpire(XLine *x) override { - ::Log(Config->GetClient("OperServ"), "expire/akill") << "AKILL on \002" << x->GetMask() << "\002 has expired"; + Anope::Logger.Bot("OperServ").Category("expire/akill").Log(_("AKILL on \002{0}\002 has expired"), + x->GetMask()); } void Send(User *u, XLine *x) override @@ -85,7 +86,7 @@ class SQLineManager : public XLineManager void OnExpire(XLine *x) override { - ::Log(Config->GetClient("OperServ"), "expire/sqline") << "SQLINE on \002" << x->GetMask() << "\002 has expired"; + Anope::Logger.Bot("OperServ").Category("expire/sqline").Log(_("SQLINE on \002{0}\002 has expired"), x->GetMask()); } void Send(User *u, XLine *x) override @@ -162,7 +163,7 @@ class SNLineManager : public XLineManager void OnExpire(XLine *x) override { - ::Log(Config->GetClient("OperServ"), "expire/snline") << "SNLINE on \002" << x->GetMask() << "\002 has expired"; + Anope::Logger.Bot("OperServ").Category("expire/snline").Log(_("SNLINE on \002{0}\002 has expired"), x->GetMask()); } void Send(User *u, XLine *x) override @@ -255,8 +256,8 @@ class OperServCore : public Module { if (bi == OperServ && !u->HasMode("OPER") && Config->GetModule(this)->Get<bool>("opersonly")) { - u->SendMessage(bi, "Access denied."); - ::Log(bi, "bados") << "Denied access to " << bi->nick << " from " << u->GetMask() << " (non-oper)"; + u->SendMessage(bi, _("Access denied.")); + logger.Bot(bi).Category("bados").Log(_("Denied access to {0} from {1} (non-oper)"), bi->nick, u->GetMask()); return EVENT_STOP; } @@ -266,19 +267,19 @@ class OperServCore : public Module void OnServerQuit(Server *server) override { if (server->IsJuped()) - ::Log(server, "squit", OperServ) << "Received SQUIT for juped server " << server->GetName(); + server->logger.Bot(OperServ).Category("squit").Log(_("Received SQUIT for juped server {0}"), server->GetName()); } void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override { if (mname == "OPER") - ::Log(u, "oper", OperServ) << "is now an IRC operator."; + u->logger.Bot(OperServ).Category("oper").Log(_("{0} is now an IRC operator."), u->GetMask()); } void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) override { if (mname == "OPER") - ::Log(u, "oper", OperServ) << "is no longer an IRC operator"; + u->logger.Bot(OperServ).Category("oper").Log(_("{0} is no longer an IRC operator"), u->GetMask()); } void OnUserConnect(User *u, bool &exempt) override @@ -310,7 +311,8 @@ class OperServCore : public Module { if (!params.empty() || source.c || source.service != *OperServ) return EVENT_CONTINUE; - source.Reply(_("%s commands:"), OperServ->nick.c_str()); + + source.Reply(_("{0} commands:"), OperServ->nick); return EVENT_CONTINUE; } @@ -318,10 +320,13 @@ class OperServCore : public Module { } - void OnLog(::Log *l) override + void OnLog(Logger *l) override { - if (l->type == LOG_SERVER) +#warning "" +#if 0 + if (l->type == LogType::SERVER) l->bi = OperServ; +#endif } }; diff --git a/modules/operserv/mode.cpp b/modules/operserv/mode.cpp index a66f8897f..6e7e0e157 100644 --- a/modules/operserv/mode.cpp +++ b/modules/operserv/mode.cpp @@ -140,7 +140,7 @@ class CommandOSMode : public Command } if (!log_modes.replace_all_cs("+", "").replace_all_cs("-", "").empty()) - Log(LOG_ADMIN, source, this) << log_modes << log_params << " on " << (c ? c->name : target); + logger.Command(LogType::ADMIN, source, _("{source} used {command} {0} on {1}"), log_modes + log_params, c ? c->name : target); } } @@ -169,16 +169,17 @@ class CommandOSUMode : public Command User *u2 = User::Find(target, true); if (!u2) - source.Reply(_("\002{0}\002 isn't currently online."), target); - else { - u2->SetModes(source.service, "%s", modes.c_str()); - source.Reply(_("Changed usermodes of \002{0}\002 to \002{1}\002."), u2->nick.c_str(), modes.c_str()); + source.Reply(_("\002{0}\002 isn't currently online."), target); + return; + } - u2->SendMessage(*source.service, _("\002{0}\002 changed your usermodes to \002{1}\002."), source.GetNick(), modes); + u2->SetModes(source.service, "%s", modes.c_str()); + source.Reply(_("Changed usermodes of \002{0}\002 to \002{1}\002."), u2->nick.c_str(), modes.c_str()); - Log(LOG_ADMIN, source, this) << modes << " on " << target; - } + u2->SendMessage(*source.service, _("\002{0}\002 changed your usermodes to \002{1}\002."), source.GetNick(), modes); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0}"), target); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/operserv/modinfo.cpp b/modules/operserv/modinfo.cpp index cd926d1e5..e1860583c 100644 --- a/modules/operserv/modinfo.cpp +++ b/modules/operserv/modinfo.cpp @@ -32,7 +32,7 @@ class CommandOSModInfo : public Command { const Anope::string &file = params[0]; - Log(LOG_ADMIN, source, this) << "on " << file; + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0}"), file); Module *m = ModuleManager::FindModule(file); if (m == nullptr) @@ -95,9 +95,10 @@ class CommandOSModList : public Command const Anope::string ¶m = !params.empty() ? params[0] : ""; if (!param.empty()) - Log(LOG_ADMIN, source, this) << "for " << param; + logger.Command(LogType::ADMIN, source, _("{source} used {command} for {0}"), param); else - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}"), + source.GetSource(), source.GetCommand()); bool third = false, vendor = false, extra = false, database = false, encryption = false, pseudoclient = false, protocol = false; diff --git a/modules/operserv/module.cpp b/modules/operserv/module.cpp index 1e4e0bac5..669638a51 100644 --- a/modules/operserv/module.cpp +++ b/modules/operserv/module.cpp @@ -35,7 +35,7 @@ class CommandOSModLoad : public Command ModuleReturn status = ModuleManager::LoadModule(mname, source.GetUser()); if (status == MOD_ERR_OK) { - Log(LOG_ADMIN, source, this) << "to load module " << mname; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to load module {0}"), mname); source.Reply(_("Module \002{0}\002 loaded."), mname); } else if (status == MOD_ERR_EXISTS) @@ -101,7 +101,7 @@ class CommandOSModReLoad : public Command status = ModuleManager::LoadModule(mname, source.GetUser()); if (status == MOD_ERR_OK) { - Log(LOG_ADMIN, source, this) << "to reload module " << mname; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to reload module {0}"), mname); source.Reply(_("Module \002{0}\002 reloaded."), mname); } else @@ -151,13 +151,11 @@ class CommandOSModUnLoad : public Command return; } - Log(this->GetOwner()) << "Trying to unload module [" << mname << "]"; - ModuleReturn status = ModuleManager::UnloadModule(m, source.GetUser()); if (status == MOD_ERR_OK) { - Log(LOG_ADMIN, source, this) << "to unload module " << mname; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to unload module {0}"), mname); source.Reply(_("Module \002{0}\002 unloaded."), mname); } else diff --git a/modules/operserv/news.cpp b/modules/operserv/news.cpp index e2119a2de..3a829f0c3 100644 --- a/modules/operserv/news.cpp +++ b/modules/operserv/news.cpp @@ -220,7 +220,8 @@ class NewsBase : public Command ni->SetWho(source.GetNick()); source.Reply(msgs[MSG_ADDED]); - Log(LOG_ADMIN, source, this) << "to add a news item"; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add news item: {0}"), text); } void DoDel(CommandSource &source, const std::vector<Anope::string> ¶ms, NewsType ntype, const char **msgs) @@ -250,9 +251,13 @@ class NewsBase : public Command unsigned num = convertTo<unsigned>(text); if (num > 0 && num <= list.size()) { - list[num - 1]->Delete(); + NewsItem *item = list[num - 1]; source.Reply(msgs[MSG_DELETED], num); - Log(LOG_ADMIN, source, this) << "to delete a news item"; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to delete news item {0}"), item->GetText()); + + item->Delete(); + return; } } @@ -265,7 +270,8 @@ class NewsBase : public Command for (NewsItem *n : list) n->Delete(); source.Reply(msgs[MSG_DELETED_ALL]); - Log(LOG_ADMIN, source, this) << "to delete all news items"; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to delete all news items")); } } diff --git a/modules/operserv/noop.cpp b/modules/operserv/noop.cpp index 329a6c338..ce3ce9f9b 100644 --- a/modules/operserv/noop.cpp +++ b/modules/operserv/noop.cpp @@ -53,7 +53,8 @@ class CommandOSNOOP : public Command IRCD->Send<messages::NOOP>(s, true); s->Extend<Anope::string>("noop", source.GetNick()); - Log(LOG_ADMIN, source, this) << "SET on " << s->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0}"), s->GetName()); + source.Reply(_("All operators from \002{0}\002 have been removed."), s->GetName()); Anope::string reason = "NOOP command used by " + source.GetNick(); @@ -70,7 +71,9 @@ class CommandOSNOOP : public Command { s->Shrink<Anope::string>("noop"); IRCD->Send<messages::NOOP>(s, false); - Log(LOG_ADMIN, source, this) << "REVOKE on " << s->GetName(); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} REVOKE on {0}"), s->GetName()); + source.Reply(_("All O:lines of \002{0}\002 have been reset."), s->GetName()); } else diff --git a/modules/operserv/oper.cpp b/modules/operserv/oper.cpp index 099cfc286..00c7e0f4d 100644 --- a/modules/operserv/oper.cpp +++ b/modules/operserv/oper.cpp @@ -97,7 +97,8 @@ class CommandOSOper : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "ADD " << na->GetNick() << " as type " << ot->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add {0} as an oper of type {1}"), na->GetNick(), ot->GetName()); + source.Reply("\002{0}\002 (\002{1}\002) added to the \002{2}\002 list.", na->GetNick(), na->GetAccount()->GetDisplay(), ot->GetName()); } else if (subcommand.equals_ci("DEL") && params.size() > 1) @@ -137,7 +138,8 @@ class CommandOSOper : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "DEL " << na->GetNick(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove {0}"), na->GetNick()); + source.Reply(_("Oper privileges removed from \002{0}\002 (\002{1}\002)."), na->GetNick(), na->GetAccount()->GetDisplay()); } else if (subcommand.equals_ci("LIST")) diff --git a/modules/operserv/reload.cpp b/modules/operserv/reload.cpp index ecff66ac2..fa79cd0d7 100644 --- a/modules/operserv/reload.cpp +++ b/modules/operserv/reload.cpp @@ -31,7 +31,7 @@ class CommandOSReload : public Command { try { - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); Configuration::Conf *new_config = new Configuration::Conf(); Configuration::Conf *old = Config; @@ -43,7 +43,7 @@ class CommandOSReload : public Command } catch (const ConfigException &ex) { - Log(this->GetOwner()) << "Error reloading configuration file: " << ex.GetReason(); + this->GetOwner()->logger.Log(_("Error reloading configuration file: {0}"), ex.GetReason()); source.Reply(_("Error reloading configuration file: {0}"), ex.GetReason()); } } diff --git a/modules/operserv/session.cpp b/modules/operserv/session.cpp index cdd230473..cb22f65b9 100644 --- a/modules/operserv/session.cpp +++ b/modules/operserv/session.cpp @@ -303,7 +303,7 @@ class CommandOSSession : public Command { const Anope::string &cmd = params[0]; - Log(LOG_ADMIN, source, this) << cmd << " " << params[1]; + logger.Command(LogType::ADMIN, source, _("{source} used {command} {0} {1}"), cmd, params[1]); if (!session_limit) source.Reply(_("Session limiting is disabled.")); @@ -422,7 +422,8 @@ class CommandOSException : public Command if (MOD_RESULT == EVENT_STOP) return; - Log(LOG_ADMIN, source, this) << "to set the session limit for " << mask << " to " << limit; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to set the session limit for {0} to {1}"), mask, limit); + source.Reply(_("Session limit for \002{0}\002 set to \002{1}\002."), mask, limit); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); @@ -452,7 +453,7 @@ class CommandOSException : public Command Exception *e = exceptions[number - 1]; - Log(LOG_ADMIN, source, this) << "to remove the session limit exception for " << e->GetMask(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove the session limit exception for {0}"), e->GetMask()); ++deleted; DoDel(source, e); @@ -473,7 +474,8 @@ class CommandOSException : public Command for (Exception *e : Serialize::GetObjects<Exception *>()) if (mask.equals_ci(e->GetMask())) { - Log(LOG_ADMIN, source, this) << "to remove the session limit exception for " << mask; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove the session limit exception for {0}"), e->GetMask()); + DoDel(source, e); source.Reply(_("\002{0}\002 deleted from session-limit exception list."), mask); found = true; @@ -728,7 +730,7 @@ class OSSession : public Module akills->AddXLine(x); akills->Send(NULL, x); - Log(OperServ, "akill/session") << "Added a temporary AKILL for \002" << akillmask << "\002 due to excessive connections"; + logger.Bot(OperServ).Category("akill/session").Log(_("Added a temporary AKILL for \002{0}\002 due to excessive connections"), akillmask); } else { @@ -776,7 +778,7 @@ class OSSession : public Module continue; ServiceBot *OperServ = Config->GetClient("OperServ"); - Log(OperServ, "expire/exception") << "Session exception for " << e->GetMask() << " has expired."; + logger.Bot(OperServ).Category("expire/exception").Log(_("Session exception for {0} has expired."), e->GetMask()); e->Delete(); } } diff --git a/modules/operserv/set.cpp b/modules/operserv/set.cpp index e23efb849..f8a63dca8 100644 --- a/modules/operserv/set.cpp +++ b/modules/operserv/set.cpp @@ -24,7 +24,7 @@ class CommandOSSet : public Command private: void DoList(CommandSource &source) { - Log(LOG_ADMIN, source, this) << "LIST"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} LIST")); const char *str; @@ -51,13 +51,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { Anope::ReadOnly = true; - Log(LOG_ADMIN, source, this) << "READONLY ON"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} READONLY ON")); source.Reply(_("Services are now in \002read-only\002 mode.")); } else if (setting.equals_ci("OFF")) { Anope::ReadOnly = false; - Log(LOG_ADMIN, source, this) << "READONLY OFF"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} READONLY OFF")); source.Reply(_("Services are now in \002read-write\002 mode.")); } else @@ -95,13 +95,15 @@ class CommandOSSet : public Command { source.GetUser()->super_admin = true; source.Reply(_("You are now a super admin.")); - Log(LOG_ADMIN, source, this) << "SUPERADMIN ON"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} SUPERADMIN ON"), + source.GetSource(), source.GetCommand()); } else if (setting.equals_ci("OFF")) { source.GetUser()->super_admin = false; source.Reply(_("You are no longer a super admin.")); - Log(LOG_ADMIN, source, this) << "SUPERADMIN OFF"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} SUPERADMIN OFF"), + source.GetSource(), source.GetCommand()); } else { @@ -122,12 +124,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { Anope::Debug = 1; - Log(LOG_ADMIN, source, this) << "DEBUG ON"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} DEBUG ON"), + source.GetSource(), source.GetCommand()); source.Reply(_("Services are now in \002debug\002 mode.")); } else if (setting.equals_ci("OFF") || setting == "0") { - Log(LOG_ADMIN, source, this) << "DEBUG OFF"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} DEBUG OFF")); Anope::Debug = 0; source.Reply(_("Services are now in \002non-debug\002 mode.")); } @@ -136,7 +139,7 @@ class CommandOSSet : public Command try { Anope::Debug = convertTo<int>(setting); - Log(LOG_ADMIN, source, this) << "DEBUG " << Anope::Debug; + logger.Command(LogType::ADMIN, source, _("{source} used {command} DEBUG {0}"), Anope::Debug); source.Reply(_("Services are now in \002debug\002 mode (level %d)."), Anope::Debug); return; } @@ -159,13 +162,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { Anope::NoExpire = true; - Log(LOG_ADMIN, source, this) << "NOEXPIRE ON"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} NOEXPIRE ON"), Anope::Debug); source.Reply(_("Services are now in \002no expire\002 mode.")); } else if (setting.equals_ci("OFF")) { Anope::NoExpire = false; - Log(LOG_ADMIN, source, this) << "NOEXPIRE OFF"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} NOEXPIRE OFF"), Anope::Debug); source.Reply(_("Services are now in \002expire\002 mode.")); } else diff --git a/modules/operserv/shutdown.cpp b/modules/operserv/shutdown.cpp index 030eb73f4..de987537f 100644 --- a/modules/operserv/shutdown.cpp +++ b/modules/operserv/shutdown.cpp @@ -29,7 +29,7 @@ class CommandOSRestart : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); Anope::QuitReason = source.command + " command received from " + source.GetNick(); Anope::Quitting = Anope::Restarting = true; } @@ -51,7 +51,7 @@ class CommandOSShutdown : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); Anope::QuitReason = source.command + " command received from " + source.GetNick(); Anope::Quitting = true; } diff --git a/modules/operserv/stats.cpp b/modules/operserv/stats.cpp index abee79cf6..e9df4cf83 100644 --- a/modules/operserv/stats.cpp +++ b/modules/operserv/stats.cpp @@ -246,7 +246,7 @@ class CommandOSStats : public Command { Anope::string extra = !params.empty() ? params[0] : ""; - Log(LOG_ADMIN, source, this) << extra; + logger.Command(LogType::ADMIN, source, _("{source} used {command} {0}"), extra); if (extra.equals_ci("RESET")) return this->DoStatsReset(source); @@ -318,7 +318,7 @@ class OSStats : public Module Server *sserver = u->server; if (sserver && sserver->IsSynced()) - Log(this, "maxusers") << "connected - new maximum user count: " << UserListByNick.size(); + u->logger.Category("maxusers").Log(_("{0} connected - new maximum user count: {1}"), u->GetMask(), UserListByNick.size()); } } }; diff --git a/modules/operserv/svs.cpp b/modules/operserv/svs.cpp index ccba9d8d1..40d37a5d7 100644 --- a/modules/operserv/svs.cpp +++ b/modules/operserv/svs.cpp @@ -68,7 +68,9 @@ class CommandOSSVSNick : public Command } source.Reply(_("\002{0}\002 is now being changed to \002{1}\002."), nick, newnick); - Log(LOG_ADMIN, source, this) << "to change " << nick << " to " << newnick; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to change {0} to {1}"), u2->nick, newnick); + IRCD->Send<messages::SVSNick>(u2, newnick, Anope::CurTime); } @@ -123,7 +125,9 @@ class CommandOSSVSJoin : public Command } IRCD->Send<messages::SVSJoin>(*source.service, target, params[1], ""); - Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to join " << params[1]; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to force {0} to join {1}"), target->nick, params[1]); + source.Reply(_("\002{0}\002 has been joined to \002{1}\002."), target->nick, params[1]); } @@ -178,11 +182,16 @@ class CommandOSSVSPart : public Command } const Anope::string &reason = params.size() > 2 ? params[2] : ""; + IRCD->Send<messages::SVSPart>(*source.service, target, params[1], reason); + if (!reason.empty()) - Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to part " << c->name << " with reason " << reason; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to force {0} to part {1} with reason {2}"), + target->nick, c->name, reason); else - Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to part " << c->name; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to force {0} to part {1}"), + target->nick, c->name); + source.Reply(_("\002{0}\002 has been parted from \002{1}\002."), target->nick, c->name); } diff --git a/modules/operserv/sxline.cpp b/modules/operserv/sxline.cpp index 2c98805f2..47133c16e 100644 --- a/modules/operserv/sxline.cpp +++ b/modules/operserv/sxline.cpp @@ -54,7 +54,7 @@ class CommandOSSXLineBase : public Command if (!x) return; - Log(LOG_ADMIN, source, this) << "to remove " << x->GetMask() << " from the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove {0} from the list"), x->GetMask()); ++deleted; x->Delete(); @@ -81,9 +81,11 @@ class CommandOSSXLineBase : public Command EventManager::Get()->Dispatch(&Event::DelXLine::OnDelXLine, source, x, this->xlm()); + source.Reply(_("\002{0}\002 deleted from the {1} list."), x->GetMask(), source.command); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove {0} from the list"), x->GetMask()); + x->Delete(); - source.Reply(_("\002{0}\002 deleted from the {1} list."), mask, source.command); - Log(LOG_ADMIN, source, this) << "to remove " << mask << " from the list"; } if (Anope::ReadOnly) @@ -184,7 +186,8 @@ class CommandOSSXLineBase : public Command for (XLine *x : this->xlm()->GetXLines()) x->Delete(); - Log(LOG_ADMIN, source, this) << "to CLEAR the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to CLEAR the list")); + source.Reply(_("The {0} list has been cleared."), source.command); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); @@ -342,8 +345,11 @@ class CommandOSSNLine : public CommandOSSXLineBase if (percent > 95) { source.Reply(_("\002{0}\002 coverage is too wide; please use a more specific mask."), mask); - Log(LOG_ADMIN, source, this) << "tried to " << source.command << " " << percent << "% of the network (" << affected << " users)"; - delete x; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} and tried to {0} {1}% of the network ({2} users)"), + source.command, percent, affected); + + x->Delete(); return; } @@ -351,7 +357,7 @@ class CommandOSSNLine : public CommandOSSXLineBase MOD_RESULT = EventManager::Get()->Dispatch(&Event::AddXLine::OnAddXLine, source, x, this->xlm()); if (MOD_RESULT == EVENT_STOP) { - delete x; + x->Delete(); return; } @@ -373,7 +379,11 @@ class CommandOSSNLine : public CommandOSSXLineBase } source.Reply(_("\002{0}\002 added to the {1} list."), mask, source.command); - Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << "), expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} ({1}), expires in {2} [affects {3} user(s) ({4}%)]"), + mask, reason, expires ? Anope::Duration(expires - Anope::CurTime) : "never", + affected, percent); + if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); } @@ -560,8 +570,10 @@ class CommandOSSQLine : public CommandOSSXLineBase if (percent > 95) { source.Reply(_("\002{0}\002 coverage is too wide; please use a more specific mask."), mask); - Log(LOG_ADMIN, source, this) << "tried to SQLine " << percent << "% of the network (" << affected << " users)"; - delete x; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} and tried to {0} {1}% of the network ({2} users)"), source.command, percent, affected); + + x->Delete(); return; } @@ -569,7 +581,7 @@ class CommandOSSQLine : public CommandOSSXLineBase MOD_RESULT = EventManager::Get()->Dispatch(&Event::AddXLine::OnAddXLine, source, x, this->xlm()); if (MOD_RESULT == EVENT_STOP) { - delete x; + x->Delete(); return; } @@ -617,7 +629,10 @@ class CommandOSSQLine : public CommandOSSXLineBase } source.Reply(_("\002{0}\002 added to the {1} list."), mask, source.command); - Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << "), expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} ({1}), expires in {2} [affects {3} user(s) ({4}%)]"), + mask, x->GetReason(), expires ? Anope::Duration(expires - Anope::CurTime) : "never", affected, percent); + if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); } diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 66e7cca61..3814cba05 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -50,7 +50,8 @@ void bahamut::senders::Akill::Send(User* u, XLine* x) x->SetID(old->GetID()); old->GetManager()->AddXLine(x); - Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); + Anope::Logger.Bot("OperServ").Category("akill").Log(_("AKILL: Added an akill for {0} because {1}#{2} matches {3}"), + x->GetMask(), u->GetMask(), u->realname, old->GetMask()); } /* ZLine if we can instead */ @@ -354,7 +355,7 @@ void bahamut::Nick::Run(MessageSource &source, const std::vector<Anope::string> Server *s = Server::Find(params[6]); if (s == nullptr) { - Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[6] << "?"; + Anope::Logger.Debug("User {0} introduced from non-existent server {1}", params[0], params[6]); return; } @@ -436,7 +437,7 @@ void bahamut::SJoin::Run(MessageSource &source, const std::vector<Anope::string> sju.second = User::Find(buf); if (!sju.second) { - Log(LOG_DEBUG) << "SJOIN for non-existent user " << buf << " on " << params[1]; + Anope::Logger.Log("SJOIN for non-existent user {0} on {1}", buf, params[1]); continue; } diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 2cb508f0e..e296229c3 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -58,8 +58,8 @@ void hybrid::senders::Akill::Send(User* u, XLine* x) old->GetManager()->AddXLine(xl); x = xl; - Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" - << u->realname << " matches " << old->GetMask(); + Anope::Logger.Bot("OperServ").Category("akill").Log(_("AKILL: Added an akill for {0} because {1}#{2} matches {3}"), + x->GetMask(), u->GetMask(), u->realname, old->GetMask()); } /* Calculate the time left before this would expire, capping it at 2 days */ @@ -451,7 +451,7 @@ void hybrid::SJoin::Run(MessageSource &source, const std::vector<Anope::string> sju.second = User::Find(buf); if (!sju.second) { - Log(LOG_DEBUG) << "SJOIN for non-existent user " << buf << " on " << params[1]; + Anope::Logger.Debug("SJOIN for non-existent user {0} on {1}", buf, params[1]); continue; } diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 381596ee6..e53a88eaa 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -78,7 +78,8 @@ void inspircd20::senders::Akill::Send(User* u, XLine* x) x->SetReason(old->GetReason()); old->GetManager()->AddXLine(x); - Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); + Anope::Logger.Bot("OperServ").Category("akill").Log(_("AKILL: Added an akill for {0} because {1}#{2} matches {3}"), + x->GetMask(), u->GetMask(), u->realname, old->GetMask()); } /* ZLine if we can instead */ @@ -360,7 +361,7 @@ void inspircd20::senders::Wallops::Send(const MessageSource &source, const Anope void inspircd20::Proto::SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent) { if (!Servers::Capab.count("CHGIDENT")) - Log() << "CHGIDENT not loaded!"; + Anope::Logger.Log("CHGIDENT not loaded!"); else Uplink::Send(Me, "CHGIDENT", nick, vIdent); } @@ -368,7 +369,7 @@ void inspircd20::Proto::SendChgIdentInternal(const Anope::string &nick, const An void inspircd20::Proto::SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost) { if (!Servers::Capab.count("CHGHOST")) - Log() << "CHGHOST not loaded!"; + Anope::Logger.Log("CHGHOST not loaded!"); else Uplink::Send(Me, "CHGHOST", nick, vhost); } @@ -666,14 +667,16 @@ void inspircd20::Capab::Run(MessageSource &source, const std::vector<Anope::stri ChannelMode *cm = ModeManager::FindChannelModeByChar(modechar[0]); if (cm == nullptr) { - Log(this->GetOwner()) << "Warning: Uplink has unknown channel mode " << modename << "=" << modechar; + this->GetOwner()->logger.Log("Warning: Uplink has unknown channel mode {0}={1}", + modename, modechar); continue; } char modesymbol = cm->type == MODE_STATUS ? (anope_dynamic_static_cast<ChannelModeStatus *>(cm))->symbol : 0; if (symbol != modesymbol) { - Log(this->GetOwner()) << "Warning: Channel mode " << modename << " has a misconfigured status character"; + this->GetOwner()->logger.Log("Warning: Channel mode {0} has a misconfigured status character", + modename); continue; } } @@ -697,7 +700,8 @@ void inspircd20::Capab::Run(MessageSource &source, const std::vector<Anope::stri UserMode *um = ModeManager::FindUserModeByChar(modechar[0]); if (um == nullptr) { - Log(this->GetOwner()) << "Warning: Uplink has unknown user mode " << modename << "=" << modechar; + this->GetOwner()->logger.Log("Warning: Uplink has unknown user mode {0}={1}", + modename, modechar); continue; } } @@ -716,7 +720,9 @@ void inspircd20::Capab::Run(MessageSource &source, const std::vector<Anope::stri Servers::Capab.insert("RLINE"); const Anope::string ®exengine = Config->GetBlock("options")->Get<Anope::string>("regexengine"); if (!regexengine.empty() && module.length() > 11 && regexengine != module.substr(11)) - Log() << "Warning: InspIRCd is using regex engine " << module.substr(11) << ", but we have " << regexengine << ". This may cause inconsistencies."; + this->GetOwner()->logger.Log("Warning: InspIRCd is using regex engine {0}, but we have {1}. " + "This may cause inconsistencies.", + module.substr(11), regexengine); } else if (module.equals_cs("m_topiclock.so")) Servers::Capab.insert("TOPICLOCK"); @@ -769,11 +775,11 @@ void inspircd20::Capab::Run(MessageSource &source, const std::vector<Anope::stri return; } if (!IRCD->CanSVSHold) - Log() << "SVSHOLD missing, Usage disabled until module is loaded."; + this->GetOwner()->logger.Log("SVSHOLD missing, Usage disabled until module is loaded."); if (!Servers::Capab.count("CHGHOST")) - Log() << "CHGHOST missing, Usage disabled until module is loaded."; + this->GetOwner()->logger.Log("CHGHOST missing, Usage disabled until module is loaded."); if (!Servers::Capab.count("CHGIDENT")) - Log() << "CHGIDENT missing, Usage disabled until module is loaded."; + this->GetOwner()->logger.Log("CHGIDENT missing, Usage disabled until module is loaded."); } rfc1459::Capab::Run(source, params); @@ -824,7 +830,7 @@ void inspircd20::Endburst::Run(MessageSource &source, const std::vector<Anope::s { Server *s = source.GetServer(); - Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName(); + s->logger.Debug("Processed ENDBURST for {0}", s->GetName()); s->Sync(true); } @@ -874,7 +880,7 @@ void inspircd20::FJoin::Run(MessageSource &source, const std::vector<Anope::stri sju.second = User::Find(buf); if (!sju.second) { - Log(LOG_DEBUG) << "FJOIN for non-existent user " << buf << " on " << params[0]; + this->GetOwner()->logger.Debug("FJOIN for non-existent user {0} on {1}", buf, params[0]); continue; } @@ -1044,7 +1050,7 @@ void inspircd20::Metadata::Run(MessageSource &source, const std::vector<Anope::s if (required) { if (!plus) - Log() << "Warning: InspIRCd unloaded module " << module << ", Anope won't function correctly without it"; + this->GetOwner()->logger.Log("Warning: InspIRCd unloaded module {0}, Anope won't function correctly without it"); } else { @@ -1053,7 +1059,7 @@ void inspircd20::Metadata::Run(MessageSource &source, const std::vector<Anope::s else Servers::Capab.erase(capab); - Log() << "InspIRCd " << (plus ? "loaded" : "unloaded") << " module " << module << ", adjusted functionality"; + this->GetOwner()->logger.Log("InspIRCd {0} module {1}, adjusted functionality", plus ? "loaded" : "unloaded", module); } } diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 7712aec8f..ce18cbbf7 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -131,7 +131,7 @@ void ngircd::Numeric005::Run(MessageSource &source, const std::vector<Anope::str unsigned newlen = convertTo<unsigned>(data), len = Config->GetBlock("networkinfo")->Get<unsigned>("nicklen"); if (len != newlen) { - Log() << "Warning: NICKLEN is " << newlen << " but networkinfo:nicklen is " << len; + Anope::Logger.Log("Warning: NICKLEN is {0} but networkinfo:nicklen is {1}", newlen, len); } } } @@ -240,10 +240,8 @@ void ngircd::Metadata::Run(MessageSource &source, const std::vector<Anope::strin { User *u = User::Find(params[0]); if (!u) - { - Log() << "received METADATA for non-existent user " << params[0]; return; - } + if (params[1].equals_cs("accountname")) { NickServ::Account *nc = NickServ::FindAccount(params[2]); @@ -339,15 +337,10 @@ void ngircd::Nick::Run(MessageSource &source, const std::vector<Anope::string> & Server *s = Server::Find(params[4]); if (s == nullptr) { - Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[4] << "?"; + Anope::Logger.Debug("User {0} introduced from non-existent server {1}", params[0], params[4]); return; } User::OnIntroduce(params[0], params[2], params[3], "", "", s, params[6], Anope::CurTime, params[5], "", NULL); - Log(LOG_DEBUG) << "Registered nick \"" << params[0] << "\" on server " << s->GetName() << "."; - } - else - { - Log(LOG_DEBUG) << "Received NICK with invalid number of parameters. source = " << source.GetName() << "params[0] = " << params[0] << "params.size() = " << params.size(); } } @@ -374,7 +367,7 @@ void ngircd::NJoin::Run(MessageSource &source, const std::vector<Anope::string> rfc1459::Join::SJoinUser sju; /* Get prefixes from the nick */ - for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) + for (char ch; !buf.empty() && (ch = ModeManager::GetStatusChar(buf[0]));) { buf.erase(buf.begin()); sju.first.AddMode(ch); @@ -383,7 +376,7 @@ void ngircd::NJoin::Run(MessageSource &source, const std::vector<Anope::string> sju.second = User::Find(buf); if (!sju.second) { - Log(LOG_DEBUG) << "NJOIN for non-existent user " << buf << " on " << params[0]; + Anope::Logger.Debug("NJOIN for non-existent user {0} on {1}", buf, params[0]); continue; } users.push_back(sju); diff --git a/modules/protocol/rfc1459.cpp b/modules/protocol/rfc1459.cpp index 1405e121e..d1ac3eeaf 100644 --- a/modules/protocol/rfc1459.cpp +++ b/modules/protocol/rfc1459.cpp @@ -165,14 +165,15 @@ void senders::Wallops::Send(const MessageSource &source, const Anope::string &ms void Away::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { + User *u = source.GetUser(); const Anope::string &msg = !params.empty() ? params[0] : ""; - EventManager::Get()->Dispatch(&Event::UserAway::OnUserAway, source.GetUser(), msg); + EventManager::Get()->Dispatch(&Event::UserAway::OnUserAway, u, msg); if (!msg.empty()) - Log(source.GetUser(), "away") << "is now away: " << msg; + u->logger.Category("away").Log(_("{0} is now away: {1}"), u->GetMask(), msg); else - Log(source.GetUser(), "away") << "is no longer away"; + u->logger.Category("away").Log(_("{0} is no longer away"), u->GetMask()); } void Capab::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) @@ -191,7 +192,7 @@ void Capab::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) void Error::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - Log(LOG_TERMINAL) << "ERROR: " << params[0]; + Anope::Logger.Terminal("ERROR: {0}", params[0]); Anope::QuitReason = "Received ERROR from uplink: " + params[0]; Anope::Quitting = true; } @@ -430,7 +431,7 @@ void Part::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) if (!c || !u->FindChannel(c)) continue; - Log(u, c, "part") << "Reason: " << (!reason.empty() ? reason : "No reason"); + c->logger.User(u).Category("part").Log(_("{0} parted {1}: {2}"), u->GetMask(), c->GetName(), !reason.empty() ? reason : "No reason"); EventManager::Get()->Dispatch(&Event::PrePartChannel::OnPrePartChannel, u, c); c->DeleteUser(u); @@ -478,7 +479,7 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m ServiceBot *bi = ServiceBot::Find(receiver); if (!bi) return; - Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << u->nick; + bi->logger.Debug("Ignored PRIVMSG without @ from {0}", u->nick); u->SendMessage(bi, _("\"/msg %s\" is no longer supported. Use \"/msg %s@%s\" or \"/%s\" instead."), bi->nick.c_str(), bi->nick.c_str(), Me->GetName().c_str(), bi->nick.c_str()); return; } @@ -518,7 +519,7 @@ void Quit::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) const Anope::string &reason = params[0]; User *user = source.GetUser(); - Log(user, "quit") << "quit (Reason: " << (!reason.empty() ? reason : "no reason") << ")"; + user->logger.Category("quit").Log(_("{0} quit: {1}"), user->GetMask(), (!reason.empty() ? reason : "no reason")); user->Quit(reason); } @@ -529,7 +530,7 @@ void SQuit::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) if (!s) { - Log(LOG_DEBUG) << "SQUIT for nonexistent server " << params[0]; + Anope::Logger.Debug("SQUIT for nonexistent server {0}", params[0]); return; } diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index f319268b7..fd6e31875 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -58,7 +58,8 @@ void unreal::senders::Akill::Send(User* u, XLine* x) old->GetManager()->AddXLine(xl); x = xl; - Log(Config->GetClient("OperServ"), "akill") << "AKILL: Added an akill for " << x->GetMask() << " because " << u->GetMask() << "#" << u->realname << " matches " << old->GetMask(); + Anope::Logger.Bot("OperServ").Category("akill").Log(_("AKILL: Added an akill for {0} because {1}#{2} matches {3}"), + x->GetMask(), u->GetMask(), u->realname, old->GetMask()); } /* ZLine if we can instead */ @@ -731,7 +732,7 @@ void unreal::Nick::Run(MessageSource &source, const std::vector<Anope::string> & Server *s = Server::Find(params[5]); if (s == NULL) { - Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[5] << "?"; + Anope::Logger.Debug("User {0} introduced from non-existent server {1}", params[0], params[5]); return; } @@ -912,7 +913,7 @@ void unreal::SJoin::Run(MessageSource &source, const std::vector<Anope::string> rfc1459::Join::SJoinUser sju; /* Get prefixes from the nick */ - for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) + for (char ch; !buf.empty() && (ch = ModeManager::GetStatusChar(buf[0]));) { sju.first.AddMode(ch); buf.erase(buf.begin()); @@ -921,7 +922,7 @@ void unreal::SJoin::Run(MessageSource &source, const std::vector<Anope::string> sju.second = User::Find(buf); if (!sju.second) { - Log(LOG_DEBUG) << "SJOIN for non-existent user " << buf << " on " << params[1]; + Anope::Logger.Debug("SJOIN for non-existent user {0} on {1}", buf, params[1]); continue; } diff --git a/modules/redis.cpp b/modules/redis.cpp index 7a519a4e7..47d89ef42 100644 --- a/modules/redis.cpp +++ b/modules/redis.cpp @@ -68,7 +68,7 @@ class Transaction : public Interface * in this transaction */ - Log(LOG_DEBUG_2) << "redis: transaction complete with " << r.multi_bulk.size() << " results"; + this->GetOwner()->logger.Debug2("transaction complete with {0} results", r.multi_bulk.size()); for (unsigned i = 0; i < r.multi_bulk.size(); ++i) { @@ -274,7 +274,7 @@ RedisSocket::~RedisSocket() void RedisSocket::OnConnect() { - Log() << "redis: Successfully connected to " << provider->GetName() << (this == this->provider->sub ? " (sub)" : ""); + provider->GetOwner()->logger.Log(_("Successfully connected to {0}"), provider->GetName() + (this == this->provider->sub ? " (sub)" : "")); this->provider->SendCommand(NULL, "CLIENT SETNAME Anope"); this->provider->SendCommand(NULL, "SELECT " + stringify(provider->db)); @@ -282,7 +282,7 @@ void RedisSocket::OnConnect() void RedisSocket::OnError(const Anope::string &error) { - Log() << "redis: Error on " << provider->GetName() << (this == this->provider->sub ? " (sub)" : "") << ": " << error; + provider->GetOwner()->logger.Log(_("Error on {0}: {1}"), provider->GetName() + (this == this->provider->sub ? " (sub)" : ""), error); } size_t RedisSocket::ParseReply(Reply &r, const char *buffer, size_t l) @@ -301,7 +301,7 @@ size_t RedisSocket::ParseReply(Reply &r, const char *buffer, size_t l) { Anope::string reason(buffer, 1, l - 1); size_t nl = reason.find("\r\n"); - Log(LOG_DEBUG_2) << "redis: status ok: " << reason.substr(0, nl); + provider->GetOwner()->logger.Debug2("status ok: {0}", reason.substr(0, nl)); if (nl != Anope::string::npos) { r.type = Reply::OK; @@ -313,7 +313,7 @@ size_t RedisSocket::ParseReply(Reply &r, const char *buffer, size_t l) { Anope::string reason(buffer, 1, l - 1); size_t nl = reason.find("\r\n"); - Log(LOG_DEBUG) << "redis: status error: " << reason.substr(0, nl); + provider->GetOwner()->logger.Debug2("status error: {0}", reason.substr(0, nl)); if (nl != Anope::string::npos) { r.type = Reply::NOT_OK; @@ -404,7 +404,7 @@ size_t RedisSocket::ParseReply(Reply &r, const char *buffer, size_t l) size_t u = ParseReply(*reply, buffer + used, l - used); if (!u) { - Log(LOG_DEBUG) << "redis: ran out of data to parse"; + provider->GetOwner()->logger.Debug("ran out of data to parse"); delete reply; break; } @@ -414,7 +414,7 @@ size_t RedisSocket::ParseReply(Reply &r, const char *buffer, size_t l) break; } default: - Log(LOG_DEBUG) << "redis: unknown reply " << *buffer; + provider->GetOwner()->logger.Debug("unknown reply {0}", *buffer); } return used; @@ -442,13 +442,13 @@ bool RedisSocket::Read(const char *buffer, size_t l) size_t used = this->ParseReply(r, buffer, l); if (!used) { - Log(LOG_DEBUG) << "redis: used == 0 ?"; + provider->GetOwner()->logger.Debug("used == 0 ?"); r.Clear(); break; } else if (used > l) { - Log(LOG_DEBUG) << "redis: used > l ?"; + provider->GetOwner()->logger.Debug("used > l ?"); r.Clear(); break; } @@ -471,7 +471,7 @@ bool RedisSocket::Read(const char *buffer, size_t l) { if (this->interfaces.empty()) { - Log(LOG_DEBUG) << "redis: no interfaces?"; + provider->GetOwner()->logger.Debug("no interfaces?"); } else { @@ -572,7 +572,7 @@ class ModuleRedis : public Module { Interface *inter = p->sock->interfaces[i - 1]; - if (inter && inter->owner == m) + if (inter && inter->GetOwner() == m) { inter->OnError(m->name + " being unloaded"); p->sock->interfaces.erase(p->sock->interfaces.begin() + i - 1); @@ -584,7 +584,7 @@ class ModuleRedis : public Module { Interface *inter = p->sub->interfaces[i - 1]; - if (inter && inter->owner == m) + if (inter && inter->GetOwner() == m) { inter->OnError(m->name + " being unloaded"); p->sub->interfaces.erase(p->sub->interfaces.begin() + i - 1); @@ -595,7 +595,7 @@ class ModuleRedis : public Module { Interface *inter = p->ti.interfaces[i - 1]; - if (inter && inter->owner == m) + if (inter && inter->GetOwner() == m) { inter->OnError(m->name + " being unloaded"); p->ti.interfaces.erase(p->ti.interfaces.begin() + i - 1); diff --git a/modules/rewrite.cpp b/modules/rewrite.cpp index c4c5575e8..0aa0897b0 100644 --- a/modules/rewrite.cpp +++ b/modules/rewrite.cpp @@ -126,14 +126,16 @@ class RewriteCommand : public Command if (r != NULL) { Anope::string new_message = r->Process(source, full_params); - Log(LOG_DEBUG) << "m_rewrite: Rewrote '" << source.command << (!params.empty() ? " " + params[0] : "") << "' to '" << new_message << "' using '" << r->source_message << "'"; + logger.Debug("Rewrote '{0}' to '{1}' using '{2}'", source.command + (!params.empty() ? " " + params[0] : ""), new_message, r->source_message); source.service = ServiceBot::Find(r->client, true); if (!source.service) return; Command::Run(source, new_message); } else - Log() << "m_rewrite: Unable to rewrite '" << source.command << (!params.empty() ? " " + params[0] : "") << "'"; + { + logger.Log("Unable to rewrite '{0}'", source.command + (!params.empty() ? " " + params[0] : "")); + } } void OnServHelp(CommandSource &source) override diff --git a/modules/sasl.cpp b/modules/sasl.cpp index d8cd83dcf..af5bdda13 100644 --- a/modules/sasl.cpp +++ b/modules/sasl.cpp @@ -120,13 +120,13 @@ class External : public Mechanism NickServ::Account *nc = certs->FindAccountFromCert(mysess->cert); if (!nc || nc->HasFieldS("NS_SUSPENDED")) { - Log(Config->GetClient("NickServ"), "sasl") << "A user failed to identify using certificate " << mysess->cert << " using SASL EXTERNAL"; + Anope::Logger.Category("sasl").Bot("nickserv").Log(_("A user failed to identify using certificate {0} using SASL EXTERNAL"), mysess->cert); GetService()->Fail(sess); delete sess; return; } - Log(Config->GetClient("NickServ"), "sasl") << "A user identified to account " << nc->GetDisplay() << " using SASL EXTERNAL"; + Anope::Logger.Category("sasl").Bot("nickserv").Log(_("A user identified to account {0} using using SASL EXTERNAL"), nc->GetDisplay()); GetService()->Succeed(sess, nc); delete sess; } @@ -298,7 +298,7 @@ void IdentifyRequestListener::OnSuccess(NickServ::IdentifyRequest *req) Session *s = service->GetSession(uid); if (s) { - Log(Config->GetClient("NickServ"), "sasl") << "A user identified to account " << req->GetAccount() << " using SASL"; + Anope::Logger.Category("sasl").Bot("NickServ").Log(_("A user identified to account {0} using SASL"), req->GetAccount()); service->Succeed(s, na->GetAccount()); delete s; } @@ -320,7 +320,8 @@ void IdentifyRequestListener::OnFail(NickServ::IdentifyRequest *req) else if (na->GetAccount()->HasFieldS("NS_SUSPENDED")) accountstatus = "suspended "; - Log(Config->GetClient("NickServ"), "sasl") << "A user failed to identify for " << accountstatus << "account " << req->GetAccount() << " using SASL"; + Anope::Logger.Category("sasl").Bot("NickServ").Log(_("A user failed to identify for {0}account {1} using SASL"), + accountstatus, req->GetAccount()); } class ModuleSASL : public Module diff --git a/modules/sqlite.cpp b/modules/sqlite.cpp index 5fbbb855e..3cc618e4c 100644 --- a/modules/sqlite.cpp +++ b/modules/sqlite.cpp @@ -139,7 +139,7 @@ class ModuleSQLite : public Module if (i == num) { - Log(LOG_NORMAL, "sqlite") << "SQLite: Removing server connection " << cname; + logger.Log("Removing server connection {0}", cname); delete s; this->SQLiteServices.erase(cname); @@ -160,11 +160,11 @@ class ModuleSQLite : public Module SQLiteService *ss = new SQLiteService(this, connname, database); this->SQLiteServices[connname] = ss; - Log(LOG_NORMAL, "sqlite") << "SQLite: Successfully added database " << database; + logger.Log(_("Successfully added database {0}"), database); } catch (const SQL::Exception &ex) { - Log(LOG_NORMAL, "sqlite") << "SQLite: " << ex.GetReason(); + logger.Log(ex.GetReason()); } } } @@ -189,7 +189,7 @@ SQLiteService::SQLiteService(Module *o, const Anope::string &n, const Anope::str int ret = sqlite3_create_function_v2(this->sql, "anope_canonicalize", 1, SQLITE_DETERMINISTIC, NULL, Canonicalize, NULL, NULL, NULL); if (ret != SQLITE_OK) - Log(LOG_DEBUG) << "Unable to add anope_canonicalize function: " << sqlite3_errmsg(this->sql); + o->logger.Debug("Unable to add anope_canonicalize function: {0}", sqlite3_errmsg(this->sql)); } SQLiteService::~SQLiteService() @@ -216,7 +216,7 @@ Result SQLiteService::RunQuery(const Query &query) { const char *msg = sqlite3_errmsg(this->sql); - Log(LOG_DEBUG) << "sqlite: error in query " << real_query << ": " << msg; + this->GetOwner()->logger.Debug("error in query {0}: {1}", real_query, msg); return SQLiteResult(query, real_query, msg); } @@ -227,9 +227,9 @@ Result SQLiteService::RunQuery(const Query &query) sqlite3_finalize(stmt); if (!result.GetError().empty()) - Log(LOG_DEBUG) << "sqlite: error executing query " << real_query << ": " << result.GetError(); + this->GetOwner()->logger.Debug("error executing query {0}: {1}", real_query, result.GetError()); else - Log(LOG_DEBUG) << "sqlite: executed: " << real_query; + this->GetOwner()->logger.Debug("executed: {0}", real_query); return result; } diff --git a/modules/webcpanel/static_fileserver.cpp b/modules/webcpanel/static_fileserver.cpp index 858336c6c..727cf3ef2 100644 --- a/modules/webcpanel/static_fileserver.cpp +++ b/modules/webcpanel/static_fileserver.cpp @@ -34,7 +34,7 @@ bool StaticFileServer::OnRequest(HTTPProvider *server, const Anope::string &page int fd = open((template_base + "/" + this->file_name).c_str(), O_RDONLY); if (fd < 0) { - Log(LOG_NORMAL, "httpd") << "Error serving file " << page_name << " (" << (template_base + "/" + this->file_name) << "): " << strerror(errno); + Anope::Logger.Category("webcpanel").Log("Error serving file {0} ({1}/{2}): {3}", page_name, template_base, this->file_name, strerror(errno)); client->SendError(HTTP_PAGE_NOT_FOUND, "Page not found"); return true; diff --git a/modules/webcpanel/template_fileserver.cpp b/modules/webcpanel/template_fileserver.cpp index 81c4c4a5f..cad35c455 100644 --- a/modules/webcpanel/template_fileserver.cpp +++ b/modules/webcpanel/template_fileserver.cpp @@ -107,7 +107,7 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n int fd = open((template_base + "/" + this->file_name).c_str(), O_RDONLY); if (fd < 0) { - Log(LOG_NORMAL, "httpd") << "Error serving file " << page_name << " (" << (template_base + "/" + this->file_name) << "): " << strerror(errno); + Anope::Logger.Category("webcpanel").Log("Error serving file {0} ({1}/{2}): {3}", page_name, template_base, this->file_name, strerror(errno)); client->SendError(HTTP_PAGE_NOT_FOUND, "Page not found"); return; @@ -161,12 +161,16 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n IfStack.push(stackok && r.count(tokens[2]) > 0); } else - Log() << "Invalid IF in web template " << this->file_name; + { + Anope::Logger.Log("Invalid IF in web template {0}", this->file_name); + } } else if (content == "ELSE") { if (IfStack.empty()) - Log() << "Invalid ELSE with no stack in web template" << this->file_name; + { + Anope::Logger.Log("Invalid ELSE with no stack in web template {0}", this->file_name); + } else { bool old = IfStack.top(); @@ -178,7 +182,7 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n else if (content == "END IF") { if (IfStack.empty()) - Log() << "END IF with empty stack?"; + Anope::Logger.Log("END IF with empty stack?"); else IfStack.pop(); } @@ -188,7 +192,9 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n spacesepstream(content).GetTokens(tokens); if (tokens.size() != 4 || tokens[2] != "IN") - Log() << "Invalid FOR in web template " << this->file_name; + { + Anope::Logger.Log("Invalid FOR in web template {0}", this->file_name); + } else { std::vector<Anope::string> temp_variables, real_variables; @@ -196,7 +202,7 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n commasepstream(tokens[3]).GetTokens(real_variables); if (temp_variables.size() != real_variables.size()) - Log() << "Invalid FOR in web template " << this->file_name << " variable mismatch"; + Anope::Logger.Log("Invalid FOR in web template {0} variable mismatch", this->file_name); else ForLoop::Stack.push_back(ForLoop(j + f, r, temp_variables, real_variables)); } @@ -204,7 +210,9 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n else if (content == "END FOR") { if (ForLoop::Stack.empty()) - Log() << "END FOR with empty stack?"; + { + Anope::Logger.Log("END FOR with empty stack?"); + } else { ForLoop &fl = ForLoop::Stack.back(); @@ -229,7 +237,9 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n spacesepstream(content).GetTokens(tokens); if (tokens.size() != 2) - Log() << "Invalid INCLUDE in web template " << this->file_name; + { + Anope::Logger.Log("Invalid INCLUDE in web template {0}", this->file_name); + } else { if (!finished.empty()) diff --git a/modules/xmlrpc.cpp b/modules/xmlrpc.cpp index 41bbfce0a..43d5c48f1 100644 --- a/modules/xmlrpc.cpp +++ b/modules/xmlrpc.cpp @@ -162,7 +162,7 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage while (GetData(content, tname, data)) { - Log(LOG_DEBUG) << "m_xmlrpc: Tag name: " << tname << ", data: " << data; + this->GetOwner()->logger.Debug("Tag name: {0}, data: {1}", tname, data); if (tname == "methodName") request.name = data; else if (tname == "name" && data == "id") diff --git a/src/bots.cpp b/src/bots.cpp index dfe46ea67..86d0a0136 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -31,11 +31,13 @@ #include "event.h" #include "modules/chanserv.h" -ServiceBot::ServiceBot(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : LocalUser(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", IRCD ? IRCD->UID_Retrieve() : "", NULL), botmodes(bmodes) +ServiceBot::ServiceBot(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) + : LocalUser(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", IRCD ? IRCD->UID_Retrieve() : "", NULL) + , botmodes(bmodes) + , logger(this) { this->type = UserType::BOT; this->lastmsg = Anope::CurTime; - this->introduced = false; EventManager::Get()->Dispatch(&Event::CreateBot::OnCreateBot, this); diff --git a/src/channels.cpp b/src/channels.cpp index aed6c7b53..2b9ea438d 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -36,19 +36,16 @@ channel_map ChannelList; std::vector<Channel *> Channel::deleting; Channel::Channel(const Anope::string &nname, time_t ts) + : logger(this) { if (nname.empty()) throw CoreException("A channel without a name ?"); this->name = nname; - this->creation_time = ts; - this->syncing = this->botchannel = false; - this->server_modetime = this->chanserv_modetime = 0; - this->server_modecount = this->chanserv_modecount = this->bouncy_modes = this->topic_ts = this->topic_time = 0; if (Me && Me->IsSynced()) - Log(NULL, this, "create"); + logger.Category("create").Log("Channel {0} was created", this->GetName()); EventManager::Get()->Dispatch(&Event::ChannelCreate::OnChannelCreate, this); } @@ -60,7 +57,7 @@ Channel::~Channel() ModeManager::StackerDel(this); if (Me && Me->IsSynced()) - Log(NULL, this, "destroy"); + logger.Category("destroy").Log("Channel {0} was destroyed", this->GetName()); if (this->ci) this->ci->c = NULL; @@ -68,6 +65,11 @@ Channel::~Channel() ChannelList.erase(this->name); } +const Anope::string &Channel::GetName() const +{ + return name; +} + void Channel::Reset() { this->modes.clear(); @@ -113,7 +115,7 @@ void Channel::CheckModes() /* Check for mode bouncing */ if (this->chanserv_modetime == Anope::CurTime && this->server_modetime == Anope::CurTime && this->server_modecount >= 3 && this->chanserv_modecount >= 3) { - Log() << "Warning: unable to set modes on channel " << this->name << ". Are your servers' U:lines configured correctly?"; + Anope::Logger.Log("Warning: unable to set modes on channel {0}. Are your servers' U:lines configured correctly?", this->GetName()); this->bouncy_modes = 1; return; } @@ -143,7 +145,7 @@ bool Channel::CheckDelete() ChanUserContainer* Channel::JoinUser(User *user, const ChannelStatus *status) { if (user->server && user->server->IsSynced()) - Log(user, this, "join"); + logger.Category("join").Log(_("{0} joined {1}"), user->GetMask(), this->GetName()); ChanUserContainer *cuc = new ChanUserContainer(user, this); user->chans[this] = cuc; @@ -157,16 +159,16 @@ ChanUserContainer* Channel::JoinUser(User *user, const ChannelStatus *status) void Channel::DeleteUser(User *user) { if (user->server && user->server->IsSynced() && !user->Quitting()) - Log(user, this, "leave"); + logger.Category("leave").Log(_("{0} left {1}"), user->GetMask(), this->GetName()); EventManager::Get()->Dispatch(&Event::LeaveChannel::OnLeaveChannel, user, this); ChanUserContainer *cu = user->FindChannel(this); if (!this->users.erase(user)) - Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete non-existent user " << user->nick << " from channel " << this->name; + logger.Debug("Channel::DeleteUser() tried to delete non-existent user {0} from channel {1}", user->GetMask(), this->GetName()); if (!user->chans.erase(this)) - Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete non-existent channel " << this->name << " from " << user->nick << "'s channel list"; + logger.Debug("Channel::DeleteUser() tried to delete non-existent channel {0} from channel list of user {1}", this->GetName(), user->GetMask()); delete cu; QueueForDeletion(); @@ -273,7 +275,7 @@ void Channel::SetModeInternal(const MessageSource &setter, ChannelMode *ocm, con { if (param.empty()) { - Log() << "Channel::SetModeInternal() mode " << cm->mchar << " with no parameter for channel " << this->name; + Anope::Logger.Log("Channel::SetModeInternal() mode {} with no parameter for channel {}", cm->mchar, this->GetName()); return; } @@ -281,11 +283,11 @@ void Channel::SetModeInternal(const MessageSource &setter, ChannelMode *ocm, con if (!u) { - Log() << "MODE " << this->name << " +" << cm->mchar << " for non-existent user " << param; + Anope::Logger.Debug("Mode +{0} for non-existent user {1} on channel {2}", cm->mchar, param, this->GetName()); return; } - Log(LOG_DEBUG) << "Setting +" << cm->mchar << " on " << this->name << " for " << u->nick; + Anope::Logger.Debug("Setting +{0} on {1} for {2}", cm->mchar, this->GetName(), u->GetMask()); /* Set the status on the user */ ChanUserContainer *cc = u->FindChannel(this); @@ -309,7 +311,7 @@ void Channel::SetModeInternal(const MessageSource &setter, ChannelMode *ocm, con if (param.empty() && cm->type != MODE_REGULAR) { - Log() << "Channel::SetModeInternal() mode " << cm->mchar << " for " << this->name << " with no paramater, but is a param mode"; + Anope::Logger.Log("Channel::SetModeInternal() mode {0} for {1} with no paramater, but is a param mode", cm->mchar, this->name); return; } @@ -337,7 +339,7 @@ void Channel::RemoveModeInternal(const MessageSource &setter, ChannelMode *ocm, { if (param.empty()) { - Log() << "Channel::RemoveModeInternal() mode " << cm->mchar << " with no parameter for channel " << this->name; + Anope::Logger.Log("Channel::RemoveModeInternal() mode {0} with no parameter for channel {1}", cm->mchar, this->GetName()); return; } @@ -345,11 +347,11 @@ void Channel::RemoveModeInternal(const MessageSource &setter, ChannelMode *ocm, if (!u) { - Log() << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->mchar << " for non-existent user " << param; + Anope::Logger.Debug("Mode -{0} for non-existent user {1} on channel {2}", cm->mchar, param, this->GetName()); return; } - Log(LOG_DEBUG) << "Setting -" << cm->mchar << " on " << this->name << " for " << u->nick; + Anope::Logger.Debug("Setting -{0} on {1} for {2}", cm->mchar, this->GetName(), u->GetMask()); /* Remove the status on the user */ ChanUserContainer *cc = u->FindChannel(this); @@ -592,12 +594,12 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode, ; else if (ts > this->creation_time) { - Log(LOG_DEBUG) << "Dropping mode " << mode << " on " << this->name << ", " << ts << " > " << this->creation_time; + Anope::Logger.Debug("Dropping mode {0} on {1}, TS {2] > {3}", mode, this->GetName(), ts, this->creation_time); return; } else if (ts < this->creation_time) { - Log(LOG_DEBUG) << "Changing TS of " << this->name << " from " << this->creation_time << " to " << ts; + Anope::Logger.Debug("Changing TS of {0} from {1} to {2}", this->GetName(), this->creation_time, ts); this->creation_time = ts; this->Reset(); } @@ -635,7 +637,7 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode, cm = ModeManager::FindChannelModeByChar(m[i]); if (!cm) { - Log(LOG_DEBUG) << "Channel::SetModeInternal: Unknown mode char " << m[i]; + Anope::Logger.Debug("Channel::SetModeInternal: Unknown mode char {0}", m[i]); continue; } modestring += cm->mchar; @@ -678,7 +680,9 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode, this->RemoveModeInternal(source, cm, token, enforce_mlock); } else - Log() << "warning: Channel::SetModesInternal() received more modes requiring params than params, modes: " << mode; + { + Anope::Logger.Log("warning: Channel::SetModesInternal() received more modes requiring params than params, modes: {0}", mode); + } } if (!this_reference) @@ -696,9 +700,9 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode, } if (setter) - Log(setter, this, "mode") << modestring << paramstring; + logger.Category("mode").Log("{0} {1}", modestring, paramstring); else - Log(LOG_DEBUG) << source.GetName() << " is setting " << this->name << " to " << modestring << paramstring; + logger.Debug("{0} is setting {1] to {2}{3}", source.GetName(), this->GetName(), modestring, paramstring); if (enforce_mlock) this->CheckModes(); @@ -724,23 +728,24 @@ bool Channel::KickInternal(const MessageSource &source, const Anope::string &nic { User *sender = source.GetUser(); User *target = User::Find(nick); + if (!target) { - Log(LOG_DEBUG) << "Channel::KickInternal got a nonexistent user " << nick << " on " << this->name << ": " << reason; + Anope::Logger.Debug("Channel::KickInternal got a nonexistent user {0} on {1}: {2}", nick, this->GetName(), reason); return false; } if (sender) - Log(sender, this, "kick") << "kicked " << target->nick << " (" << reason << ")"; + logger.User(sender).Category("kick").Log(_("{0} kicked {1} from {2} ({3})"), sender->GetMask(), target->GetMask(), this->GetName(), reason); else - Log(target, this, "kick") << "was kicked by " << source.GetName() << " (" << reason << ")"; + logger.Category("kick").Log(_("{0} kicked {1} from {2} ({3})"), source.GetName(), target->GetMask(), this->GetName(), reason); Anope::string chname = this->name; ChanUserContainer *cu = target->FindChannel(this); if (cu == NULL) { - Log(LOG_DEBUG) << "Channel::KickInternal got kick for user " << target->nick << " from " << source.GetSource() << " who isn't on channel " << this->name; + Anope::Logger.Debug("Kick for user {0} who is not in channel {1}", target->GetMask(), this->GetName()); return false; } @@ -778,7 +783,7 @@ void Channel::ChangeTopicInternal(User *u, const Anope::string &user, const Anop this->topic_ts = ts; this->topic_time = Anope::CurTime; - Log(LOG_DEBUG) << "Topic of " << this->name << " changed by " << this->topic_setter << " to " << newtopic; + Anope::Logger.Debug("Topic of {0} changed by {1} to {2}", this->GetName(), this->topic_setter, newtopic); EventManager::Get()->Dispatch(&Event::TopicUpdated::OnTopicUpdated, u, this, user, this->topic); } @@ -805,7 +810,7 @@ void Channel::SetCorrectModes(User *user, bool give_modes) if (!this->ci) return; - Log(LOG_DEBUG) << "Setting correct user modes for " << user->nick << " on " << this->name << " (" << (give_modes ? "" : "not ") << "giving modes)"; + Anope::Logger.Debug("Setting correct user modes for {0} on {1} ({2}giving modes)", user->nick, this->name, give_modes ? "" : "not "); ChanServ::AccessGroup u_access = ci->AccessFor(user); @@ -892,7 +897,7 @@ bool Channel::CheckKick(User *user) if (reason.empty()) reason = Language::Translate(user->Account(), _("You are not permitted to be on this channel.")); - Log(LOG_DEBUG) << "Autokicking " << user->nick << " (" << mask << ") from " << this->name; + Anope::Logger.Debug("Autokicking {0} ({1}) from {2}", user->nick, mask, this->name); this->SetMode(NULL, "BAN", mask); this->Kick(NULL, user, reason); diff --git a/src/command.cpp b/src/command.cpp index 7a87b07f3..9095c0526 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -31,8 +31,12 @@ #include "modules/botserv.h" #include "modules/chanserv.h" -CommandSource::CommandSource(const Anope::string &n, User *user, NickServ::Account *core, CommandReply *r, ServiceBot *bi) : nick(n), u(user), nc(core), reply(r), - c(NULL), service(bi) +CommandSource::CommandSource(const Anope::string &n, User *user, NickServ::Account *core, CommandReply *r, ServiceBot *bi) + : nick(n) + , u(user) + , nc(core) + , reply(r) + , service(bi) { } @@ -51,6 +55,24 @@ NickServ::Account *CommandSource::GetAccount() return this->nc; } +Anope::string CommandSource::GetSource() +{ + if (u) + if (nc) + return this->u->GetMask() + " (" + this->nc->GetDisplay() + ")"; + else + return this->u->GetMask(); + else if (nc) + return nc->GetDisplay(); + else + return this->nick; +} + +const Anope::string &CommandSource::GetCommand() const +{ + return this->command; +} + ChanServ::AccessGroup CommandSource::AccessFor(ChanServ::Channel *ci) { if (this->u) @@ -120,9 +142,12 @@ void CommandSource::Reply(const Anope::string &message) this->reply->SendMessage(*this->service, tok); } -Command::Command(Module *o, const Anope::string &sname, size_t minparams, size_t maxparams) : Service(o, NAME, sname), max_params(maxparams), min_params(minparams), module(o) +Command::Command(Module *o, const Anope::string &sname, size_t minparams, size_t maxparams) : Service(o, NAME, sname) + , max_params(maxparams) + , min_params(minparams) + , module(o) + , logger(this) { - allow_unregistered = require_user = false; } Command::~Command() @@ -234,7 +259,7 @@ void Command::Run(CommandSource &source, const Anope::string &message) source.Reply(_("Unknown command \002{0}\002. \"{1}{2} HELP\" for help."), message, Config->StrictPrivmsg, source.service->nick); else source.Reply(_("Unknown command \002{0}\002."), message); - Log(source.service) << "Command " << it->first << " exists on me, but its service " << info.name << " was not found!"; + source.service->logger.Log("Command {0} exists on me, but its service {1} was not found!", it->first, info.name); return; } @@ -260,7 +285,7 @@ void Command::Run(CommandSource &source, const Anope::string &cmdname, const Com { source.Reply(_("Password authentication required for that command.")); if (source.GetUser()) - Log(LOG_NORMAL, "access_denied_unreg", source.service) << "Access denied for unregistered user " << source.GetUser()->GetMask() << " with command " << cmdname; + Anope::Logger.User(source.service).Category("access_denied_unreg").Log(_("Access denied for unregistered user {0} with command {1}"), source.GetUser()->GetMask(), cmdname); return; } @@ -285,7 +310,7 @@ void Command::Run(CommandSource &source, const Anope::string &cmdname, const Com else source.Reply(_("Access denied. You do not have access to command \002{0}\002."), info.permission); if (source.GetUser()) - Log(LOG_NORMAL, "access_denied", source.service) << "Access denied for user " << source.GetUser()->GetMask() << " with command " << cmdname; + Anope::Logger.User(source.service).Category("access_denied").Log(_("Access denied for user {0} with command {1}"), source.GetUser()->GetMask(), cmdname); return; } diff --git a/src/config.cpp b/src/config.cpp index e34177e8f..fbac466d9 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -307,7 +307,7 @@ Conf::Conf() : Block("") if (ot2->GetName().equals_ci(str)) { - Log() << "Inheriting commands and privs from " << ot2->GetName() << " to " << ot->GetName(); + Anope::Logger.Log(_("Inheriting commands and privs from {0} to {1}"), ot2->GetName(), ot->GetName()); ot->Inherits(ot2); break; } @@ -528,7 +528,7 @@ Conf::Conf() : Block("") /* Check the user keys */ if (!options->Get<unsigned>("seed")) - Log() << "Configuration option options:seed should be set. It's for YOUR safety! Remember that!"; + Anope::Logger.Log(_("Configuration option options:seed should be set. It's for YOUR safety! Remember that!")); /* check regexengine */ const Anope::string ®ex_engine = options->Get<Anope::string>("regexengine"); @@ -725,7 +725,7 @@ void Conf::LoadOpers() ot = this->MyOperTypes[j]; if (ot == NULL) { - Log() << "Oper block for " << nname << " has invalid oper type " << type; + Anope::Logger.Log(_("Oper block for {0} has invalid oper type {1}"), nname, type); continue; } @@ -741,7 +741,7 @@ void Conf::LoadOpers() o->SetHost(host); o->SetVhost(vhost); - Log(LOG_DEBUG) << "Creating oper " << nname << " of type " << ot->GetName(); + Anope::Logger.Debug(_("Creating oper {0} of type {1}"), nname, ot->GetName()); } /* Apply new opers */ @@ -752,7 +752,7 @@ void Conf::LoadOpers() continue; na->GetAccount()->SetOper(o); - Log() << "Tied oper " << na->GetAccount()->GetDisplay() << " to type " << o->GetType()->GetName(); + Anope::Logger.Log(_("Tied oper {0} to type {1}"), na->GetAccount()->GetDisplay(), o->GetType()->GetName()); } } @@ -896,7 +896,7 @@ void Conf::LoadConf(File &file) int linenumber = 0; bool in_word = false, in_quote = false, in_comment = false; - Log(LOG_DEBUG) << "Start to read conf " << file.GetName(); + Anope::Logger.Debug("Start to read conf {0}", file.GetName()); // Start reading characters... while (!file.End()) { @@ -907,7 +907,7 @@ void Conf::LoadConf(File &file) if (line.empty() && in_quote) wordbuffer += "\n"; - for (unsigned c = 0, len = line.length(); c < len; ++c) + for (unsigned int c = 0, len = line.length(); c < len; ++c) { char ch = line[c]; if (in_quote) @@ -1056,7 +1056,7 @@ void Conf::LoadConf(File &file) Block *b = block_stack.top(); if (b) - Log(LOG_DEBUG) << "ln " << linenumber << " EOL: s='" << b->name << "' '" << itemname << "' set to '" << wordbuffer << "'"; + Anope::Logger.Debug("ln {0} EOL: s='{1}' '{2}' set to '{3}'", linenumber, b->name, itemname, wordbuffer); /* Check defines */ for (int i = 0; i < this->CountBlock("define"); ++i) diff --git a/src/extensible.cpp b/src/extensible.cpp index dc468fae7..524d74be3 100644 --- a/src/extensible.cpp +++ b/src/extensible.cpp @@ -39,7 +39,7 @@ bool Extensible::HasExtOK(const Anope::string &name) if (ref) return ref->HasExt(this); - Log(LOG_DEBUG) << "HasExt for nonexistent type " << name << " on " << static_cast<const void *>(this); + Anope::Logger.Debug("HasExt for nonexistent type {0} on {1}", name, static_cast<const void *>(this)); return false; } diff --git a/src/init.cpp b/src/init.cpp index 92cc70e9a..2922edaf1 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -144,18 +144,18 @@ void Anope::HandleSignal() } catch (const ConfigException &ex) { - Log() << "Error reloading configuration file: " << ex.GetReason(); + Anope::Logger.Log("Error reloading configuration file: {0}", ex.GetReason()); } break; } case SIGTERM: case SIGINT: #ifndef _WIN32 - Log() << "Received " << strsignal(Signal) << " signal (" << Signal << "), exiting."; + Anope::Logger.Log(_("Received {0} signal ({1}), exiting"), strsignal(Signal), Signal); Anope::QuitReason = Anope::string("Services terminating via signal ") + strsignal(Signal) + " (" + stringify(Signal) + ")"; #else - Log() << "Received signal " << Signal << ", exiting."; - Anope::QuitReason = Anope::string("Services terminating via signal ") + stringify(Signal); + Anope::Logger.Log(_("Received signal {0}, exiting"), Signal); + Anope::QuitReason = "Services terminating via signal " + stringify(Signal); #endif Anope::Quitting = true; break; @@ -248,7 +248,7 @@ static void setuidgid() errno = 0; struct passwd *u = getpwnam(options->Get<Anope::string>("user").c_str()); if (u == NULL) - Log() << "Unable to setuid to " << options->Get<Anope::string>("user") << ": " << Anope::LastError(); + Anope::Logger.Log(_("Unable to setuid to {0}: {1}"), options->Get<Anope::string>("user"), Anope::LastError()); else uid = u->pw_uid; } @@ -257,7 +257,7 @@ static void setuidgid() errno = 0; struct group *g = getgrnam(options->Get<Anope::string>("group").c_str()); if (g == NULL) - Log() << "Unable to setgid to " << options->Get<Anope::string>("group") << ": " << Anope::LastError(); + Anope::Logger.Log(_("Unable to setgid to {0}: {1}"), options->Get<Anope::string>("group"), Anope::LastError()); else gid = g->gr_gid; } @@ -277,16 +277,16 @@ static void setuidgid() if (static_cast<int>(gid) != -1) { if (setgid(gid) == -1) - Log() << "Unable to setgid to " << options->Get<Anope::string>("group") << ": " << Anope::LastError(); + Anope::Logger.Log(_("Unable to setgid to {0}: {1}"), options->Get<Anope::string>("group"), Anope::LastError()); else - Log() << "Successfully set group to " << options->Get<Anope::string>("group"); + Anope::Logger.Log(_("Successfully set group to {0"), options->Get<Anope::string>("group")); } if (static_cast<int>(uid) != -1) { if (setuid(uid) == -1) - Log() << "Unable to setuid to " << options->Get<Anope::string>("user") << ": " << Anope::LastError(); + Anope::Logger.Log(_("Unable to setuid to {0}: {1}"), options->Get<Anope::string>("user"), Anope::LastError()); else - Log() << "Successfully set user to " << options->Get<Anope::string>("user"); + Anope::Logger.Log(_("Successfully set user to {0}"), options->Get<Anope::string>("user")); } #endif } @@ -303,33 +303,33 @@ void Anope::Init(int ac, char **av) if (GetCommandLineArgument("version", 'v')) { - Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- Built: " << Anope::VersionBuildTime() << " -- Flags: " << Anope::VersionFlags(); + Anope::Logger.Terminal(_("Anope-{0} -- Built: {1} -- Flags: {2}"), Anope::Version(), Anope::VersionBuildTime(), Anope::VersionFlags()); exit(EXIT_SUCCESS); } if (GetCommandLineArgument("help", 'h')) { - Log(LOG_TERMINAL) << "Anope-" << Anope::Version(); - Log(LOG_TERMINAL) << "Anope IRC Services (https://anope.org)"; - Log(LOG_TERMINAL) << "Usage ./" << Anope::ServicesBin << " [options] ..."; - Log(LOG_TERMINAL) << "-c, --config=filename.conf"; - Log(LOG_TERMINAL) << " --confdir=conf file direcory"; - Log(LOG_TERMINAL) << " --dbdir=database directory"; - Log(LOG_TERMINAL) << "-d, --debug[=level]"; - Log(LOG_TERMINAL) << "-h, --help"; - Log(LOG_TERMINAL) << " --localedir=locale directory"; - Log(LOG_TERMINAL) << " --logdir=logs directory"; - Log(LOG_TERMINAL) << " --modulesdir=modules directory"; - Log(LOG_TERMINAL) << "-e, --noexpire"; - Log(LOG_TERMINAL) << "-n, --nofork"; - Log(LOG_TERMINAL) << " --nothird"; - Log(LOG_TERMINAL) << " --protocoldebug"; - Log(LOG_TERMINAL) << "-r, --readonly"; - Log(LOG_TERMINAL) << "-s, --support"; - Log(LOG_TERMINAL) << "-v, --version"; - Log(LOG_TERMINAL) << ""; - Log(LOG_TERMINAL) << "Further support is available from https://anope.org"; - Log(LOG_TERMINAL) << "Or visit us on IRC at irc.anope.org #anope"; + Anope::Logger.Terminal(_("Anope-{0}"), Anope::Version()); + Anope::Logger.Terminal(_("Anope IRC Services (https://anope.org)")); + Anope::Logger.Terminal(_("Usage ./{0} [options] ..."), Anope::ServicesBin); + Anope::Logger.Terminal(_("-c, --config=filename.conf")); + Anope::Logger.Terminal(_(" --confdir=conf file direcory")); + Anope::Logger.Terminal(_(" --dbdir=database directory")); + Anope::Logger.Terminal(_("-d, --debug[=level]")); + Anope::Logger.Terminal(_("-h, --help")); + Anope::Logger.Terminal(_(" --localedir=locale directory")); + Anope::Logger.Terminal(_(" --logdir=logs directory")); + Anope::Logger.Terminal(_(" --modulesdir=modules directory")); + Anope::Logger.Terminal(_("-e, --noexpire")); + Anope::Logger.Terminal(_("-n, --nofork")); + Anope::Logger.Terminal(_(" --nothird")); + Anope::Logger.Terminal(_(" --protocoldebug")); + Anope::Logger.Terminal(_("-r, --readonly")); + Anope::Logger.Terminal(_("-s, --support")); + Anope::Logger.Terminal(_("-v, --version")); + Anope::Logger.Terminal(""); + Anope::Logger.Terminal(_("Further support is available from https://anope.org")); + Anope::Logger.Terminal(_("Or visit us on IRC at irc.anope.org #anope")); exit(EXIT_SUCCESS); } @@ -417,7 +417,7 @@ void Anope::Init(int ac, char **av) throw CoreException("Unable to chdir to " + Anope::ServicesDir + ": " + Anope::LastError()); } - Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- Built: " << Anope::VersionBuildTime() << " -- Flags: " << Anope::VersionFlags(); + Anope::Logger.Terminal("Anope-{0} -- Built: {1} -- Flags: {2}", Anope::Version(), Anope::VersionBuildTime(), Anope::VersionFlags()); #ifdef _WIN32 if (!SupportedWindowsVersion()) @@ -439,9 +439,9 @@ void Anope::Init(int ac, char **av) #endif #ifdef _WIN32 - Log(LOG_TERMINAL) << "Using configuration file " << Anope::ConfigDir << "\\" << ServicesConf.GetName(); + Anope::Logger.Terminal("Using configuration file {0}\\{1}", Anope::ConfigDir, ServicesConf.GetName()); #else - Log(LOG_TERMINAL) << "Using configuration file " << Anope::ConfigDir << "/" << ServicesConf.GetName(); + Anope::Logger.Terminal("Using configuration file {0}/{1}", Anope::ConfigDir, ServicesConf.GetName()); /* Fork to background */ if (!Anope::NoFork) @@ -471,7 +471,7 @@ void Anope::Init(int ac, char **av) } else if (i == -1) { - Log() << "Error, unable to fork: " << Anope::LastError(); + Anope::Logger.Terminal("Error, unable to fork: {0}", Anope::LastError()); Anope::NoFork = true; } @@ -499,11 +499,11 @@ void Anope::Init(int ac, char **av) } catch (const ConfigException &ex) { - Log(LOG_TERMINAL) << ex.GetReason(); - Log(LOG_TERMINAL) << "*** Support resources: Read through the anope.conf self-contained"; - Log(LOG_TERMINAL) << "*** documentation. Read the documentation files found in the 'docs'"; - Log(LOG_TERMINAL) << "*** folder. Visit our portal located at https://anope.org/. Join"; - Log(LOG_TERMINAL) << "*** our support channel on irc.anope.org #anope."; + Anope::Logger.Terminal(ex.GetReason()); + Anope::Logger.Terminal("*** Support resources: Read through the anope.conf self-contained"); + Anope::Logger.Terminal("*** documentation. Read the documentation files found in the 'docs'"); + Anope::Logger.Terminal("*** folder. Visit our portal located at https://anope.org/. Join"); + Anope::Logger.Terminal("*** our support channel on irc.anope.org #anope."); throw CoreException("Configuration file failed to validate"); } @@ -522,7 +522,12 @@ void Anope::Init(int ac, char **av) } /* Announce ourselves to the logfile. */ - Log() << "Anope " << Anope::Version() << " starting up" << (Anope::Debug || Anope::ReadOnly ? " (options:" : "") << (Anope::Debug ? " debug" : "") << (Anope::ReadOnly ? " readonly" : "") << (Anope::Debug || Anope::ReadOnly ? ")" : ""); + if (Anope::Debug || Anope::ReadOnly) + Anope::Logger.Log("Anope {0} starting up ({1})", + Anope::Version(), + Anope::Format("options:{0}{1}", Anope::Debug ? " debug" : "", Anope::ReadOnly ? " readonly" : "")); + else + Anope::Logger.Log("Anope {0} starting up", Anope::Version()); InitSignals(); @@ -536,7 +541,7 @@ void Anope::Init(int ac, char **av) ModeManager::Apply(nullptr); /* load modules */ - Log() << "Loading modules..."; + Anope::Logger.Log("Loading modules..."); for (int i = 0; i < Config->CountBlock("module"); ++i) ModuleManager::LoadModule(Config->GetBlock("module", i)->Get<Anope::string>("name"), NULL); @@ -556,7 +561,7 @@ void Anope::Init(int ac, char **av) /* Write our PID to the PID file. */ write_pidfile(); - Log() << "Using IRCd protocol " << protocol->name; + Anope::Logger.Log("Using IRCd protocol {0}", protocol->GetName()); /* Auto assign sid if applicable */ if (IRCD->RequiresID) @@ -576,10 +581,9 @@ void Anope::Init(int ac, char **av) } /* Load up databases */ - Log() << "Loading databases..."; - EventReturn MOD_RESULT = EventManager::Get()->Dispatch(&Event::LoadDatabase::OnLoadDatabase);; - static_cast<void>(MOD_RESULT); - Log() << "Databases loaded"; + Anope::Logger.Log("Loading databases..."); + EventManager::Get()->Dispatch(&Event::LoadDatabase::OnLoadDatabase);; + Anope::Logger.Log("Databases loaded"); for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) it->second->Sync(); diff --git a/src/language.cpp b/src/language.cpp index 8c3e6221a..238449aaa 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -34,14 +34,14 @@ std::vector<Anope::string> Language::Domains; void Language::InitLanguages() { #if GETTEXT_FOUND - Log(LOG_DEBUG) << "Initializing Languages..."; + Anope::Logger.Debug("Initializing Languages..."); Languages.clear(); if (!bindtextdomain("anope", Anope::LocaleDir.c_str())) - Log() << "Error calling bindtextdomain, " << Anope::LastError(); + Anope::Logger.Log("Error calling bindtextdomain, {0}", Anope::LastError()); else - Log(LOG_DEBUG) << "Successfully bound anope to " << Anope::LocaleDir; + Anope::Logger.Debug("Successfully bound anope to {0}", Anope::LocaleDir); setlocale(LC_ALL, ""); @@ -52,15 +52,15 @@ void Language::InitLanguages() const Anope::string &lang_name = Translate(language.c_str(), _("English")); if (lang_name == "English") { - Log() << "Unable to use language " << language; + Anope::Logger.Log("Unable to use language {0}", language); continue; } - Log(LOG_DEBUG) << "Found language " << language; + Anope::Logger.Debug("Found language {0}", language); Languages.push_back(language); } #else - Log() << "Unable to initialize languages, gettext is not installed"; + Anope::Logger.Log("Unable to initialize languages, gettext is not installed"); #endif } @@ -109,7 +109,12 @@ const char *Language::Translate(const char *lang, const char *string) return ""; if (!lang || !*lang) + { + if (Config == nullptr) + return string; + lang = Config->DefLanguage.c_str(); + } #ifdef __USE_GNU_GETTEXT ++_nl_msg_cat_cntr; diff --git a/src/logger.cpp b/src/logger.cpp index 2751382f6..f6e961ee8 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -29,6 +29,7 @@ #include "uplink.h" #include "protocol.h" #include "event.h" +#include "anope.h" #include "modules/nickserv.h" #include "modules/chanserv.h" @@ -57,7 +58,9 @@ static Anope::string GetTimeStamp() strftime(s, sizeof(tbuf) - (s - tbuf) - 1, " %Y]", &tm); } else + { strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S %Y]", &tm); + } return tbuf; } @@ -85,161 +88,7 @@ const Anope::string &LogFile::GetName() const return this->filename; } -Log::Log(LogType t, const Anope::string &cat, ServiceBot *b) : bi(b), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(t), category(cat) -{ -} - -Log::Log(LogType t, CommandSource &src, Command *_c, ChanServ::Channel *_ci) : u(src.GetUser()), nc(src.nc), c(_c), source(&src), chan(NULL), ci(_ci), s(NULL), m(NULL), type(t) -{ - if (!c) - throw CoreException("Invalid pointers passed to Log::Log"); - - if (type != LOG_COMMAND && type != LOG_OVERRIDE && type != LOG_ADMIN) - throw CoreException("This constructor does not support this log type"); - - size_t sl = c->GetName().find('/'); - this->bi = NULL; - if (sl != Anope::string::npos) - this->bi = ServiceBot::Find(c->GetName().substr(0, sl), true); - this->category = c->GetName(); -} - -Log::Log(User *_u, Channel *ch, const Anope::string &cat) : bi(NULL), u(_u), nc(NULL), c(NULL), source(NULL), chan(ch), ci(chan ? *chan->ci : NULL), s(NULL), m(NULL), type(LOG_CHANNEL), category(cat) -{ - if (!chan) - throw CoreException("Invalid pointers passed to Log::Log"); -} - -Log::Log(User *_u, const Anope::string &cat, ServiceBot *_bi) : bi(_bi), u(_u), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_USER), category(cat) -{ - if (!u) - throw CoreException("Invalid pointers passed to Log::Log"); -} - -Log::Log(Server *serv, const Anope::string &cat, ServiceBot *_bi) : bi(_bi), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(serv), m(NULL), type(LOG_SERVER), category(cat) -{ - if (!s) - throw CoreException("Invalid pointer passed to Log::Log"); -} - -Log::Log(ServiceBot *b, const Anope::string &cat) : bi(b), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_NORMAL), category(cat) -{ -} - -Log::Log(Module *mod, const Anope::string &cat, ServiceBot *_bi) : bi(_bi), u(NULL), nc(NULL), c(NULL), source(NULL), chan(NULL), ci(NULL), s(NULL), m(mod), type(LOG_MODULE), category(cat) -{ -} - -Log::~Log() -{ - if (Anope::NoFork && Anope::Debug && this->type >= LOG_NORMAL && this->type <= LOG_DEBUG + Anope::Debug - 1) - std::cout << GetTimeStamp() << " Debug: " << this->BuildPrefix() << this->buf.str() << std::endl; - else if (Anope::NoFork && this->type <= LOG_TERMINAL) - std::cout << GetTimeStamp() << " " << this->BuildPrefix() << this->buf.str() << std::endl; - else if (this->type == LOG_TERMINAL) - std::cout << this->BuildPrefix() << this->buf.str() << std::endl; - - /* Some of the higher debug messages are in the event/service system which manages event dispatch, - * so firing off the log event here can cause them to be in weird states - */ - if (this->type <= LOG_NORMAL) - { - EventManager *em = EventManager::Get(); - if (em != nullptr) - em->Dispatch(&Event::Log::OnLog, this); - } - - if (Config) - for (unsigned i = 0; i < Config->LogInfos.size(); ++i) - if (Config->LogInfos[i].HasType(this->type, this->category)) - Config->LogInfos[i].ProcessMessage(this); -} - -Anope::string Log::FormatSource() const -{ - if (u) - if (nc) - return this->u->GetMask() + " (" + this->nc->GetDisplay() + ")"; - else - return this->u->GetMask(); - else if (nc) - return nc->GetDisplay(); - return ""; -} - -Anope::string Log::FormatCommand() const -{ - Anope::string buffer = FormatSource() + " used " + (source != NULL && !source->command.empty() ? source->command : this->c->GetName()) + " "; - if (this->ci) - buffer += "on " + this->ci->GetName() + " "; - - return buffer; -} - -Anope::string Log::BuildPrefix() const -{ - Anope::string buffer; - - switch (this->type) - { - case LOG_ADMIN: - { - if (!this->c) - break; - buffer += "ADMIN: " + FormatCommand(); - break; - } - case LOG_OVERRIDE: - { - if (!this->c) - break; - buffer += "OVERRIDE: " + FormatCommand(); - break; - } - case LOG_COMMAND: - { - if (!this->c) - break; - buffer += "COMMAND: " + FormatCommand(); - break; - } - case LOG_CHANNEL: - { - if (!this->chan) - break; - buffer += "CHANNEL: "; - Anope::string src = FormatSource(); - if (!src.empty()) - buffer += src + " "; - buffer += this->category + " " + this->chan->name + " "; - break; - } - case LOG_USER: - { - if (this->u) - buffer += "USERS: " + FormatSource() + " "; - break; - } - case LOG_SERVER: - { - if (this->s) - buffer += "SERVER: " + this->s->GetName() + " (" + this->s->GetDescription() + ") "; - break; - } - case LOG_MODULE: - { - if (this->m) - buffer += this->m->name.upper() + ": "; - break; - } - default: - break; - } - - return buffer; -} - -LogInfo::LogInfo(int la, bool rio, bool ldebug) : bot(NULL), last_day(0), log_age(la), raw_io(rio), debug(ldebug) +LogInfo::LogInfo(int la, bool rio, bool ldebug) : log_age(la), raw_io(rio), debug(ldebug) { } @@ -250,41 +99,44 @@ LogInfo::~LogInfo() this->logfiles.clear(); } -bool LogInfo::HasType(LogType ltype, const Anope::string &type) const +bool LogInfo::HasType(LogType ltype, LogLevel level, const Anope::string &type) const { + switch (level) + { + case LogLevel::TERMINAL: + return true; + case LogLevel::RAWIO: + return (Anope::Debug || this->debug) ? true : this->raw_io; + case LogLevel::DEBUG: + return Anope::Debug ? true : this->debug; + case LogLevel::DEBUG_2: + case LogLevel::DEBUG_3: + return; + } + const std::vector<Anope::string> *list = NULL; switch (ltype) { - case LOG_ADMIN: + case LogType::ADMIN: list = &this->admin; break; - case LOG_OVERRIDE: + case LogType::OVERRIDE: list = &this->override; break; - case LOG_COMMAND: + case LogType::COMMAND: list = &this->commands; break; - case LOG_SERVER: + case LogType::SERVER: list = &this->servers; break; - case LOG_CHANNEL: + case LogType::CHANNEL: list = &this->channels; break; - case LOG_USER: + case LogType::USER: list = &this->users; break; - case LOG_TERMINAL: - return true; - case LOG_RAWIO: - return (Anope::Debug || this->debug) ? true : this->raw_io; - case LOG_DEBUG: - return Anope::Debug ? true : this->debug; - case LOG_DEBUG_2: - case LOG_DEBUG_3: - case LOG_DEBUG_4: - break; - case LOG_MODULE: - case LOG_NORMAL: + case LogType::MODULE: + case LogType::NORMAL: default: list = &this->normal; break; @@ -293,7 +145,7 @@ bool LogInfo::HasType(LogType ltype, const Anope::string &type) const if (list == NULL) return false; - for (unsigned i = 0; i < list->size(); ++i) + for (unsigned int i = 0; i < list->size(); ++i) { Anope::string cat = list->at(i); bool inverse = false; @@ -327,7 +179,7 @@ void LogInfo::OpenLogFiles() LogFile *lf = new LogFile(CreateLogName(target)); if (!lf->stream.is_open()) { - Log() << "Unable to open logfile " << lf->GetName(); + Anope::Logger.Log("Unable to open logfile {0}", lf->GetName()); delete lf; } else @@ -335,7 +187,7 @@ void LogInfo::OpenLogFiles() } } -void LogInfo::ProcessMessage(const Log *l) +void LogInfo::ProcessMessage(const Logger *l, const Anope::string &message) { if (!this->sources.empty()) { @@ -344,26 +196,29 @@ void LogInfo::ProcessMessage(const Log *l) { const Anope::string &src = this->sources[i]; - if (l->bi && src == l->bi->nick) + if (l->GetBot() && src == l->GetBot()->nick) log = true; - else if (l->u && src == l->u->nick) + else if (l->GetUser() && src == l->GetUser()->nick) log = true; - else if (l->nc && src == l->nc->GetDisplay()) + else if (l->GetAccount() && src == l->GetAccount()->GetDisplay()) log = true; - else if (l->ci && src == l->ci->GetName()) + else if (l->GetCi() && src == l->GetCi()->GetName()) log = true; - else if (l->m && src == l->m->name) + else if (l->GetModule() && src == l->GetModule()->name) log = true; - else if (l->s && src == l->s->GetName()) + else if (l->GetServer() && src == l->GetServer()->GetName()) log = true; } if (!log) return; } - const Anope::string &buffer = l->BuildPrefix() + l->buf.str(); + const Anope::string &buffer = l->BuildPrefix() + message; - EventManager::Get()->Dispatch(&Event::LogMessage::OnLogMessage, this, l, buffer); + if (l->GetLevel() <= LogLevel::NORMAL) + { + EventManager::Get()->Dispatch(&Event::LogMessage::OnLogMessage, this, l, buffer); + } for (unsigned i = 0; i < this->targets.size(); ++i) { @@ -371,13 +226,13 @@ void LogInfo::ProcessMessage(const Log *l) if (!target.empty() && target[0] == '#') { - if (UplinkSock && l->type <= LOG_NORMAL && Me && Me->IsSynced()) + if (UplinkSock && l->type == LogType::NORMAL && Me && Me->IsSynced()) { Channel *c = Channel::Find(target); if (!c) continue; - User *bi = l->bi; + User *bi = l->GetBot(); if (!bi) bi = this->bot; if (!bi) @@ -388,9 +243,9 @@ void LogInfo::ProcessMessage(const Log *l) } else if (target == "opers") { - if (UplinkSock && l->bi && l->type <= LOG_NORMAL && Me && Me->IsSynced()) + if (UplinkSock && l->GetBot() && l->type == LogType::NORMAL && Me && Me->IsSynced()) { - IRCD->SendWallops(l->bi, buffer); + IRCD->SendWallops(l->GetBot(), buffer); } } } @@ -413,7 +268,7 @@ void LogInfo::ProcessMessage(const Log *l) if (IsFile(oldlog)) { unlink(oldlog.c_str()); - Log(LOG_DEBUG) << "Deleted old logfile " << oldlog; + Anope::Logger.Debug("Deleted old logfile {0}", oldlog); } } } @@ -425,3 +280,213 @@ void LogInfo::ProcessMessage(const Log *l) } } +void Logger::InsertVariables(FormatInfo &fi) +{ + if (user != nullptr) + fi.Add("user"_kw = user->GetMask()); + + if (ci != nullptr) + fi.Add("channel"_kw = ci->GetName()); + else if (channel != nullptr) + fi.Add("channel"_kw = channel->GetName()); + + fi.Add("source"_kw = this->FormatSource()); + + if (source != nullptr && !source->GetCommand().empty()) + fi.Add("command"_kw = source->GetCommand()); + else if (command != nullptr) + fi.Add("command"_kw = command->GetName()); +} + +Anope::string Logger::FormatSource() const +{ + if (user) + if (account) + return user->GetMask() + " (" + account->GetDisplay() + ")"; + else + return user->GetMask(); + else if (account) + return account->GetDisplay(); + else if (source) + return source->GetNick(); + return ""; +} + +Anope::string Logger::BuildPrefix() const +{ + switch (this->type) + { + case LogType::ADMIN: + return "ADMIN: "; + case LogType::OVERRIDE: + return "OVERRIDE: "; + case LogType::COMMAND: + return "COMMAND: "; + case LogType::SERVER: + return "SERVER: "; + case LogType::CHANNEL: + return "CHANNEL: "; + case LogType::USER: + return "USER: "; + case LogType::MODULE: + return this->module != nullptr ? (this->module->name.upper() + ": ") : ""; + } + + return ""; +} + +void Logger::LogMessage(const Anope::string &message) +{ + if (Anope::NoFork && Anope::Debug && level >= LogLevel::NORMAL && static_cast<int>(level) <= static_cast<int>(LogLevel::DEBUG) + Anope::Debug - 1) + std::cout << GetTimeStamp() << " Debug: " << this->BuildPrefix() << message << std::endl; + else if (Anope::NoFork && level <= LogLevel::TERMINAL) + std::cout << GetTimeStamp() << " " << this->BuildPrefix() << message << std::endl; + else if (level == LogLevel::TERMINAL) + std::cout << this->BuildPrefix() << message << std::endl; + + if (level <= LogLevel::NORMAL) + { + EventManager *em = EventManager::Get(); + if (em != nullptr) + em->Dispatch(&Event::Log::OnLog, this); + } + + if (Config != nullptr) + for (LogInfo &info : Config->LogInfos) + if (info.HasType(this->type, this->level, this->category)) + info.ProcessMessage(this, message); +} + +LogType Logger::GetType() const +{ + return type; +} + +LogLevel Logger::GetLevel() const +{ + return level; +} + +Module *Logger::GetModule() const +{ + return module; +} + +Command *Logger::GetCommand() const +{ + return command; +} + +ServiceBot *Logger::GetBot() const +{ + return bot; +} + +Server *Logger::GetServer() const +{ + return server; +} + +User *Logger::GetUser() const +{ + return user; +} + +void Logger::SetUser(class User *u) +{ + user = u; +} + +NickServ::Account *Logger::GetAccount() const +{ + return account; +} + +void Logger::SetAccount(NickServ::Account *acc) +{ + account = acc; +} + +Channel *Logger::GetChannel() const +{ + return channel; +} + +void Logger::SetChannel(class Channel *c) +{ + channel = c; +} + +ChanServ::Channel *Logger::GetCi() const +{ + return ci; +} + +void Logger::SetCi(ChanServ::Channel *c) +{ + ci = c; +} + +CommandSource *Logger::GetSource() const +{ + return source; +} + +void Logger::SetSource(CommandSource *s) +{ + source = s; + if (s != nullptr) + { + SetUser(s->GetUser()); + SetAccount(s->GetAccount()); + SetChannel(s->c); + } +} + +Logger Logger::Category(const Anope::string &c) const +{ + Logger l = *this; + l.category = c; + return l; +} + +Logger Logger::User(class User *u) const +{ + Logger l = *this; + l.user = u; + return l; +} + +Logger Logger::Channel(class Channel *c) const +{ + Logger l = *this; + l.channel = c; + return l; +} + +Logger Logger::Channel(ChanServ::Channel *c) const +{ + Logger l = *this; + l.ci = c; + return l; +} + +Logger Logger::Source(CommandSource *s) const +{ + Logger l = *this; + l.source = s; + return l; +} + +Logger Logger::Bot(ServiceBot *bot) const +{ + Logger l = *this; + l.bot = bot; + return l; +} + +Logger Logger::Bot(const Anope::string &bot) const +{ + return Bot(Config ? Config->GetClient(bot) : nullptr); +} + diff --git a/src/mail.cpp b/src/mail.cpp index 02a39bd13..51068178d 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -31,9 +31,9 @@ Mail::Message::Message(const Anope::string &sf, const Anope::string &mailto, con Mail::Message::~Message() { if (success) - Log(LOG_NORMAL, "mail") << "Successfully delivered mail for " << mail_to << " (" << addr << ")"; + Anope::Logger.Category("mail").Log(_("Successfully delivered mail for {0} ({1})"), mail_to, addr); else - Log(LOG_NORMAL, "mail") << "Error delivering mail for " << mail_to << " (" << addr << ")"; + Anope::Logger.Category("mail").Log(_("Error delivering mail for {0} ({1})"), mail_to, addr); } void Mail::Message::Run() diff --git a/src/main.cpp b/src/main.cpp index 5a97da7d8..b171c9794 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,6 +43,7 @@ sig_atomic_t Anope::Signal = 0; bool Anope::Quitting = false; bool Anope::Restarting = false; Anope::string Anope::QuitReason; +Logger Anope::Logger; static Anope::string BinaryDir; /* Full path to services bin directory */ @@ -128,7 +129,7 @@ int main(int ac, char **av, char **envp) } catch (const CoreException &ex) { - Log() << ex.GetReason(); + Anope::Logger.Log(ex.GetReason()); return -1; } @@ -138,7 +139,7 @@ int main(int ac, char **av, char **envp) } catch (const SocketException &ex) { - Log(LOG_TERMINAL) << "Unable to connect to uplink #" << (Anope::CurrentUplink + 1) << " (" << Config->Uplinks[Anope::CurrentUplink].host << ":" << Config->Uplinks[Anope::CurrentUplink].port << "): " << ex.GetReason(); + Anope::Logger.Terminal(_("Unable to connect to uplink #{0} ({1}:{2}): {3}"), Anope::CurrentUplink + 1, Config->Uplinks[Anope::CurrentUplink].host, Config->Uplinks[Anope::CurrentUplink].port, ex.GetReason()); } /* Set up timers */ @@ -148,7 +149,7 @@ int main(int ac, char **av, char **envp) /*** Main loop. ***/ while (!Anope::Quitting) { - Log(LOG_DEBUG_2) << "Top of main loop"; + Anope::Logger.Debug2("Top of main loop"); /* Process timers */ if (Anope::CurTime - last_check >= Config->TimeoutCheck) @@ -175,7 +176,7 @@ int main(int ac, char **av, char **envp) if (Anope::QuitReason.empty()) Anope::QuitReason = "Terminating, reason unknown"; - Log() << Anope::QuitReason; + Anope::Logger.Log(Anope::QuitReason); delete UplinkSock; @@ -196,7 +197,7 @@ int main(int ac, char **av, char **envp) Anope::string sbin = "./" + Anope::ServicesBin; av[0] = const_cast<char *>(sbin.c_str()); execve(Anope::ServicesBin.c_str(), av, envp); - Log() << "Restart failed"; + Anope::Logger.Log("Restart failed"); Anope::ReturnValue = -1; } diff --git a/src/misc.cpp b/src/misc.cpp index 863bca2b7..939d06498 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -411,7 +411,7 @@ bool Anope::Match(const Anope::string &str, const Anope::string &mask, bool case } catch (const std::regex_error &error) { - Log(LOG_DEBUG) << error.what(); + Anope::Logger.Debug(error.what()); } } @@ -697,7 +697,7 @@ Anope::string Anope::Resolve(const Anope::string &host, int type) memset(&hints, 0, sizeof(hints)); hints.ai_family = type; - Log(LOG_DEBUG_2) << "Resolver: BlockingQuery: Looking up " << host; + Anope::Logger.Debug2("Resolver: BlockingQuery: Looking up {0}", host); addrinfo *addrresult = NULL; if (getaddrinfo(host.c_str(), NULL, &hints, &addrresult) == 0) @@ -705,7 +705,7 @@ Anope::string Anope::Resolve(const Anope::string &host, int type) sockaddrs addr; memcpy(&addr, addrresult->ai_addr, addrresult->ai_addrlen); result = addr.addr(); - Log(LOG_DEBUG_2) << "Resolver: " << host << " -> " << result; + Anope::Logger.Debug2("Resolver: {0} -> {1}", host, result); freeaddrinfo(addrresult); } @@ -728,3 +728,40 @@ Anope::string Anope::Random(size_t len) return buf; } +const kwarg *FormatInfo::GetKwarg(const Anope::string &name) const +{ + for (const kwarg &kw : parameters) + if (kw.name == name) + return &kw; + return nullptr; +} + +void FormatInfo::Format() +{ + size_t start = 0; + size_t s = format.find('{', start); + + while (s != Anope::string::npos) + { + size_t e = format.find('}', s + 1); + if (e == Anope::string::npos) + break; + + Anope::string key = format.substr(s + 1, e - s - 1); + + // Find replacement for key + const kwarg *arg = GetKwarg(key); + + format.erase(s, e - s + 1); + if (arg != nullptr) + format.insert(s, arg->value); + + start = s + (arg != nullptr ? arg->value.length() : 0); + s = format.find('{', start); + } +} + +const Anope::string &FormatInfo::GetFormat() const +{ + return format; +} diff --git a/src/modes.cpp b/src/modes.cpp index 348ec4542..f845f7408 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -733,13 +733,13 @@ void ModeManager::Apply(Configuration::Conf *old) ChannelMode *mode; if (cm.list) - Log(LOG_DEBUG) << "Creating channelmode list " << cm.name << " (" << cm.character << ")"; + Anope::Logger.Log("Creating channelmode list {0} ({1})", cm.name, cm.character); else if (cm.status) - Log(LOG_DEBUG) << "Creating channelmode status " << cm.name << " (" << cm.character << ")"; + Anope::Logger.Log("Creating channelmode status {0} ({1})", cm.name, cm.character); else if (cm.param) - Log(LOG_DEBUG) << "Creating channelmode param " << cm.name << " (" << cm.character << ")"; + Anope::Logger.Log("Creating channelmode param {0} ({1})", cm.name, cm.character); else - Log(LOG_DEBUG) << "Creating channelmode " << cm.name << " (" << cm.character << ")"; + Anope::Logger.Log("Creating channelmode {0} ({1})", cm.name, cm.character); if (cm.list) mode = new ChannelModeList(cm.name, cm.character); @@ -761,7 +761,7 @@ void ModeManager::Apply(Configuration::Conf *old) { UserMode *mode; - Log(LOG_DEBUG) << "Creating usermode " << um.name << " (" << um.character << ")"; + Anope::Logger.Log("Creating usermode {0} ({1})", um.name, um.character); if (um.param) mode = new UserModeParam(um.name, um.character); @@ -840,7 +840,7 @@ Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh this->host = cidr_ip; this->family = addr.family(); - Log(LOG_DEBUG) << "Ban " << mask << " has cidr " << this->cidr_len; + Anope::Logger.Log("Ban {0} has cidr {1}", mask, this->cidr_len); } } catch (const ConvertException &) { } diff --git a/src/module.cpp b/src/module.cpp index 73ab9ad99..7269800d5 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -25,7 +25,10 @@ # include <libintl.h> #endif -Module::Module(const Anope::string &modname, const Anope::string &, ModType modtype) : name(modname), type(modtype) +Module::Module(const Anope::string &modname, const Anope::string &, ModType modtype) + : name(modname) + , type(modtype) + , logger(this) { this->handle = NULL; this->permanent = false; @@ -33,7 +36,9 @@ Module::Module(const Anope::string &modname, const Anope::string &, ModType modt this->SetVersion(Anope::Version()); if (type & VENDOR) + { this->SetAuthor("Anope"); + } else { /* Not vendor implies third */ @@ -50,7 +55,7 @@ Module::Module(const Anope::string &modname, const Anope::string &, ModType modt ModuleManager::Modules.push_back(this); #if GETTEXT_FOUND - for (unsigned i = 0; i < Language::Languages.size(); ++i) + for (unsigned int i = 0; i < Language::Languages.size(); ++i) { /* Remove .UTF-8 or any other suffix */ Anope::string lang; @@ -59,10 +64,12 @@ Module::Module(const Anope::string &modname, const Anope::string &, ModType modt if (Anope::IsFile(Anope::LocaleDir + "/" + lang + "/LC_MESSAGES/" + modname + ".mo")) { if (!bindtextdomain(this->name.c_str(), Anope::LocaleDir.c_str())) - Log() << "Error calling bindtextdomain, " << Anope::LastError(); + { + Anope::Logger.Log("Error calling bindtextdomain, {0}", Anope::LastError()); + } else { - Log() << "Found language file " << lang << " for " << modname; + Anope::Logger.Log("Found language file {0} for {1}", lang, modname); Language::Domains.push_back(modname); } break; @@ -87,6 +94,11 @@ Module::~Module() #endif } +const Anope::string &Module::GetName() const +{ + return this->name; +} + void Module::SetPermanent(bool state) { this->permanent = state; diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 204421f34..d4883eccb 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -48,12 +48,12 @@ void ModuleManager::CleanupRuntimeDirectory() { Anope::string dirbuf = Anope::DataDir + "/runtime"; - Log(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment please wait"; + Anope::Logger.Debug("Cleaning out Module run time directory ({0}) - this may take a moment please wait", dirbuf); DIR *dirp = opendir(dirbuf.c_str()); if (!dirp) { - Log(LOG_DEBUG) << "Cannot open directory (" << dirbuf << ")"; + Anope::Logger.Debug("Cannot open directory ({0})", dirbuf); return; } @@ -104,7 +104,7 @@ static ModuleReturn moduleCopyFile(const Anope::string &name, Anope::string &out output = tmp_output; free(tmp_output); - Log(LOG_DEBUG_2) << "Runtime module location: " << output; + Anope::Logger.Debug2("Runtime module location: {0}", output); std::ofstream target(output.c_str(), std::ios_base::in | std::ios_base::binary); if (!target.is_open()) @@ -139,7 +139,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) if (FindModule(modname)) return MOD_ERR_EXISTS; - Log(LOG_DEBUG) << "Trying to load module: " << modname; + Anope::Logger.Debug("Trying to load module: {0}", modname); #ifdef _WIN32 /* Generate the filename for the temporary copy of the module */ @@ -150,9 +150,9 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) if (ret != MOD_ERR_OK) { if (ret == MOD_ERR_NOEXIST) - Log(LOG_TERMINAL) << "Error while loading " << modname << " (file does not exist)"; + Anope::Logger.Terminal(_("Error while loading {0} (file does not exist)"), modname); else if (ret == MOD_ERR_FILE_IO) - Log(LOG_TERMINAL) << "Error while loading " << modname << " (file IO error, check file permissions and diskspace)"; + Anope::Logger.Terminal(_("Error while loading {0} (file IO error, check file permissions and diskspace)"), modname); return ret; } #else @@ -165,7 +165,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) if (!handle) { if (err && *err) - Log() << err; + Anope::Logger.Log(err); return MOD_ERR_NOLOAD; } @@ -174,9 +174,9 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) err = dlerror(); if (!module || module->api_version != ANOPE_MODAPI_VER) { - Log() << "No module symbols function found, not an Anope module"; + Anope::Logger.Log("No module symbols function found, not an Anope module"); if (err && *err) - Log(LOG_DEBUG) << err; + Anope::Logger.Log(err); dlclose(handle); return MOD_ERR_NOLOAD; } @@ -187,31 +187,31 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) if (v.GetMajor() < Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() < Anope::VersionMinor())) { - Log() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionShort(); + Anope::Logger.Log(_("Module {0} is compiled against an older version of Anope {1}.{2}, this is {3}"), modname, v.GetMajor(), v.GetMinor(), Anope::VersionShort()); dlclose(handle); return MOD_ERR_VERSION; } else if (v.GetMajor() > Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() > Anope::VersionMinor())) { - Log() << "Module " << modname << " is compiled against a newer version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionShort(); + Anope::Logger.Log(_("Module {0} is compiled against a newer version of Anope {1}.{2}, this is {3}"), modname, v.GetMajor(), v.GetMinor(), Anope::VersionShort()); dlclose(handle); return MOD_ERR_VERSION; } else if (v.GetPatch() < Anope::VersionPatch()) { - Log() << "Module " << modname << " is compiled against an older version of Anope, " << v.GetMajor() << "." << v.GetMinor() << "." << v.GetPatch() << ", this is " << Anope::VersionShort(); + Anope::Logger.Log(_("Module {0} is compiled against an older version of Anope, {1}.{2}.{3}, this is {4}"), modname, v.GetMajor(), v.GetMinor(), v.GetPatch(), Anope::VersionShort()); dlclose(handle); return MOD_ERR_VERSION; } else if (v.GetPatch() > Anope::VersionPatch()) { - Log() << "Module " << modname << " is compiled against a newer version of Anope, " << v.GetMajor() << "." << v.GetMinor() << "." << v.GetPatch() << ", this is " << Anope::VersionShort(); + Anope::Logger.Log(_("Module {0} is compiled against a newer version of Anope, {1}.{2}.{3}, this is {4}"), modname, v.GetMajor(), v.GetMinor(), v.GetPatch(), Anope::VersionShort()); dlclose(handle); return MOD_ERR_VERSION; } else { - Log(LOG_DEBUG_2) << "Module " << modname << " is compiled against current version of Anope " << Anope::VersionShort(); + Anope::Logger.Debug2("Module {0} is compiled against current version of Anope {1}", Anope::VersionShort()); } } catch (const ModuleException &ex) @@ -237,14 +237,14 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) } catch (const ModuleException &ex) { - Log() << "Error while loading " << modname << ": " << ex.GetReason(); + Anope::Logger.Log(_("Error while loading {0}: {1}"), modname, ex.GetReason()); moderr = MOD_ERR_EXCEPTION; } if (moderr != MOD_ERR_OK) { if (dlclose(handle)) - Log() << dlerror(); + Anope::Logger.Log(dlerror()); return moderr; } @@ -260,12 +260,12 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) } catch (const ModuleException &ex) { - Log() << "Module " << modname << " couldn't load:" << ex.GetReason(); + Anope::Logger.Log(_("Module {0} couldn't load: {1}"), modname, ex.GetReason()); moderr = MOD_ERR_EXCEPTION; } catch (const ConfigException &ex) { - Log() << "Module " << modname << " couldn't load due to configuration problems: " << ex.GetReason(); + Anope::Logger.Log(_("Module {0} couldn't load due to configuration problems: {1}"), modname, ex.GetReason()); moderr = MOD_ERR_EXCEPTION; } @@ -275,7 +275,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) return moderr; } - Log(LOG_DEBUG) << "Module " << modname << " loaded."; + Anope::Logger.Log(_("Module {0} loaded"), modname); EventManager::Get()->Dispatch(&Event::ModuleLoad::OnModuleLoad, u, m); @@ -352,7 +352,7 @@ ModuleReturn ModuleManager::DeleteModule(Module *m) void *handle = m->handle; Anope::string filename = m->filename; - Log(LOG_DEBUG) << "Unloading module " << m->name; + Anope::Logger.Log("Unloading module {0}", m->name); ModuleDef *def = m->def; AnopeModule *module = m->module; @@ -362,7 +362,7 @@ ModuleReturn ModuleManager::DeleteModule(Module *m) dlerror(); if (dlclose(handle)) - Log() << dlerror(); + Anope::Logger.Log(dlerror()); #ifdef _WIN32 if (!filename.empty()) diff --git a/src/process.cpp b/src/process.cpp index 8512a188f..afb12b352 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -27,7 +27,7 @@ void Anope::Process(const Anope::string &buffer) { /* If debugging, log the buffer */ - Log(LOG_RAWIO) << "Received: " << buffer; + Anope::Logger.RawIO("Received: {0}", buffer); if (buffer.empty()) return; @@ -39,19 +39,19 @@ void Anope::Process(const Anope::string &buffer) if (Anope::ProtocolDebug) { - Log() << "Source : " << (source.empty() ? "No source" : source); - Log() << "Command: " << command; + Anope::Logger.Log("Source : {0}", source.empty() ? "No source" : source); + Anope::Logger.Log("Command: {0}", command); if (params.empty()) - Log() << "No params"; + Anope::Logger.Log("No params"); else - for (unsigned i = 0; i < params.size(); ++i) - Log() << "params " << i << ": " << params[i]; + for (unsigned int i = 0; i < params.size(); ++i) + Anope::Logger.Log("params {0}: {1}", i, params[i]); } if (command.empty()) { - Log(LOG_DEBUG) << "No command? " << buffer; + Anope::Logger.Debug("No command? {0}", buffer); return; } @@ -77,16 +77,16 @@ void Anope::ProcessCommand(MessageSource &src, const Anope::string &command, con buffer += " :" + params[params.size() - 1]; } - Log(LOG_DEBUG) << "unknown command from server (" << buffer << ")"; + Anope::Logger.Debug("unknown command from server ({0})", buffer); return; } if (m->HasFlag(IRCDMESSAGE_SOFT_LIMIT) ? (params.size() < m->GetParamCount()) : (params.size() != m->GetParamCount())) - Log(LOG_DEBUG) << "invalid parameters for " << command << ": " << params.size() << " != " << m->GetParamCount(); + Anope::Logger.Debug("invalid parameters for {0}: {1} != {2}", command, params.size(), m->GetParamCount()); else if (m->HasFlag(IRCDMESSAGE_REQUIRE_USER) && !src.GetUser()) - Log(LOG_DEBUG) << "unexpected non-user source " << src.GetSource() << " for " << command; + Anope::Logger.Debug("unexpected non-user source {0} for {1}", src.GetSource(), command); else if (m->HasFlag(IRCDMESSAGE_REQUIRE_SERVER) && !src.GetServer()) - Log(LOG_DEBUG) << "unexpected non-server source " << (src.GetSource().empty() ? "(no source)" : src.GetSource()) << " for " << command; + Anope::Logger.Debug("unexpected non-server source {0} for {1}", src.GetSource().empty() ? "(no source)" : src.GetSource(), command); else m->Run(src, params); } diff --git a/src/serialize.cpp b/src/serialize.cpp index 4717c5948..d27950f36 100644 --- a/src/serialize.cpp +++ b/src/serialize.cpp @@ -56,7 +56,7 @@ void Serialize::GC() continue; } - Log(LOG_DEBUG_2) << "garbage collected object " << o->id; + Anope::Logger.Debug2("garbage collected object {0}", o->id); it = objects.erase(it); delete o; @@ -123,7 +123,7 @@ Object::Object(TypeBase *type) type->objects.insert(this); - Log(LOG_DEBUG_2) << "Creating object id #" << id << " address " << static_cast<void *>(this) << " type " << type->GetName(); + Anope::Logger.Debug2("Creating object id #{0} address {1} type {2}", id, static_cast<void *>(this), type->GetName()); EventManager::Get()->Dispatch(&Event::SerializeEvents::OnSerializableCreate, this); } @@ -137,12 +137,12 @@ Object::Object(TypeBase *type, ID i) type->objects.insert(this); - Log(LOG_DEBUG_2) << "Creating object from id #" << id << " address " << static_cast<void *>(this) << " type " << type->GetName(); + Anope::Logger.Debug2("Creating object from id #{0} address {1} type {2}", id, static_cast<void *>(this), type->GetName()); } Object::~Object() { - Log(LOG_DEBUG_2) << "Destructing object id #" << id << " address " << static_cast<void *>(this) << " type " << s_type->GetName(); + Anope::Logger.Debug2("Destructing object id #{0} address {2} type {3}", id, static_cast<void *>(this), s_type->GetName()); /* Remove in memory edges */ std::map<TypeBase *, std::vector<Edge>> copy = edges; @@ -151,12 +151,12 @@ Object::~Object() { if (!edge.direction) { - Log(LOG_DEBUG_2) << "Removing edge from object id #" << edge.other->id << " type " << edge.other->GetSerializableType()->GetName() << " on field " << edge.field->serialize_name; + Anope::Logger.Debug2("Removing edge from object id #{0} type {1} on field {2}", edge.other->id, edge.other->GetSerializableType()->GetName(), edge.field->serialize_name); edge.other->RemoveEdge(this, edge.field); } else { - Log(LOG_DEBUG_2) << "Removing edge to object id #" << edge.other->id << " type " << edge.other->GetSerializableType()->GetName() << " on field " << edge.field->serialize_name; + Anope::Logger.Debug2("Removing edge to object id #{0} type {1} on field {2}", edge.other->id, edge.other->GetSerializableType()->GetName(), edge.field->serialize_name); this->RemoveEdge(edge.other, edge.field); } } @@ -167,7 +167,7 @@ Object::~Object() void Object::Delete() { - Log(LOG_DEBUG_2) << "Deleting object id #" << id << " type " << s_type->GetName(); + Anope::Logger.Debug2("Deleting object id #{0} type {1}", id, s_type->GetName()); /* Delete dependant objects */ for (const Edge &edge : GetEdges(nullptr)) @@ -180,12 +180,12 @@ void Object::Delete() if (field->depends) { - Log(LOG_DEBUG_2) << "Deleting dependent object #" << other->id << " type " << other->GetSerializableType()->GetName() << " due to edge on " << field->serialize_name; + Anope::Logger.Debug2("Deleting dependent object #{0} type {1} due to edge on {2}", other->id, other->GetSerializableType()->GetName(), field->serialize_name); other->Delete(); } else { - Log(LOG_DEBUG_2) << "Unsetting field " << field->serialize_name << " on object #" << other->id << " type " << other->GetSerializableType()->GetName(); + Anope::Logger.Debug2("Unsetting field {0} on object #{1} type {2}", field->serialize_name, other->id, other->GetSerializableType()->GetName()); field->UnsetS(other); } } @@ -210,7 +210,7 @@ void Object::RemoveEdge(Object *other, FieldBase *field) if (it != myedges.end()) myedges.erase(it); else - Log(LOG_DEBUG_2) << "Unable to locate edge for removal on #" << this->id << " type " << s_type->GetName() << " -> #" << other->id << " type " << other->GetSerializableType()->GetName(); + Anope::Logger.Debug2("Unable to locate edge for removal on #{0} type {1} -> #{2} type {3}", this->id, s_type->GetName(), other->id, other->GetSerializableType()->GetName()); if (myedges.empty()) this->edges.erase(other->GetSerializableType()); @@ -220,7 +220,7 @@ void Object::RemoveEdge(Object *other, FieldBase *field) if (it != theiredges.end()) theiredges.erase(it); else - Log(LOG_DEBUG_2) << "Unable to locate edge for removal on #" << this->id << " type " << s_type->GetName() << " <- #" << other->id << " type " << other->GetSerializableType()->GetName(); + Anope::Logger.Debug2("Unable to locate edge for removal on #{0} type {1} <- #{2} type {3}", this->id, s_type->GetName(), other->id, other->GetSerializableType()->GetName()); if (theiredges.empty()) other->edges.erase(this->GetSerializableType()); @@ -238,7 +238,7 @@ TypeBase::~TypeBase() void TypeBase::Unregister() { - Log(LOG_DEBUG_2) << "Unregistering type " << this->GetName(); + Anope::Logger.Debug2("Unregistering type {0}", this->GetName()); for (Object *obj : GetObjects<Object *>(this->GetName())) obj->Delete(); @@ -259,7 +259,7 @@ Serialize::FieldBase *TypeBase::GetField(const Anope::string &fname) if (fb->serialize_type == this->GetName() && fb->serialize_name == fname) return fb; - Log(LOG_DEBUG_2) << "GetField() for unknown field " << fname << " on " << this->GetName(); + Anope::Logger.Debug2("GetField() for unknown field {0} on {1}", fname, this->GetName()); return nullptr; } @@ -303,7 +303,7 @@ FieldBase::~FieldBase() void FieldBase::Unregister() { - Log(LOG_DEBUG_2) << "Unregistering field " << serialize_name << " on " << serialize_type; + Anope::Logger.Debug2("Unregistering field {0} on {1}", serialize_name, serialize_type); /* find edges on this field */ for (Object *s : Serialize::GetObjects<Object *>(serialize_type)) @@ -312,7 +312,7 @@ void FieldBase::Unregister() for (const Edge &edge : p.second) if (edge.direction && edge.field == this) { - Log(LOG_DEBUG_2) << "Removing edge on #" << s->id << " type " << s->GetSerializableType()->GetName() << " -> #" << edge.other->id << " type " << edge.other->GetSerializableType()->GetName(); + Anope::Logger.Debug2("Removing edge on #{0} type {1} -> #{2} type {3}", s->id, s->GetSerializableType()->GetName(), edge.other->id, edge.other->GetSerializableType()->GetName()); s->RemoveEdge(edge.other, edge.field); goto cont; @@ -334,7 +334,7 @@ std::vector<Serialize::TypeBase *> Serialize::GetTypes(const Anope::string &name if (t != nullptr) v.push_back(t); else - Log(LOG_DEBUG_2) << "GetTypes for unknown type " << name; + Anope::Logger.Debug2("GetTypes for unknown type {0}", name); auto its = child_types.equal_range(name); for (; its.first != its.second; ++its.first) diff --git a/src/servers.cpp b/src/servers.cpp index a04e36ded..7747f4a69 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -36,7 +36,7 @@ Anope::map<Server *> Servers::ByID; std::set<Anope::string> Servers::Capab; -Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Anope::string &desc, const Anope::string &ssid, bool jupe) : name(sname), hops(shops), description(desc), sid(ssid), uplink(up), users(0) +Server::Server(Server *up, const Anope::string &sname, unsigned int shops, const Anope::string &desc, const Anope::string &ssid, bool jupe) : name(sname), hops(shops), description(desc), sid(ssid), uplink(up), users(0) { syncing = true; juped = jupe; @@ -46,7 +46,7 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano if (!ssid.empty()) Servers::ByID[ssid] = this; - Log(this, "connect") << "has connected to the network (uplinked to " << (this->uplink ? this->uplink->GetName() : "no uplink") << ")"; + this->logger.Category("connect").Log(_("{0} has connected to the network (uplinked to {1})"), this->GetName(), this->uplink ? this->uplink->GetName() : "no uplink"); /* Add this server to our uplinks leaf list */ if (this->uplink) @@ -63,7 +63,7 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano Server::~Server() { - Log(this, "quit") << "quit from " << (this->uplink ? this->uplink->GetName() : "no uplink") << " for " << this->quit_reason; + this->logger.Category("quit").Log(_("{0} quit from {1} for {2}"), this->GetName(), this->uplink ? this->uplink->GetName() : "no uplink", this->quit_reason); for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { @@ -76,7 +76,7 @@ Server::~Server() } } - Log(LOG_DEBUG) << "Finished removing all users for " << this->GetName(); + this->logger.Debug("Finished removing all users for {0}", this->GetName()); if (this->uplink) this->uplink->DelLink(this); @@ -207,7 +207,7 @@ void Server::AddLink(Server *s) { this->links.push_back(s); - Log(this, "connect") << "introduced " << s->GetName(); + this->logger.Category("connect").Log(_("{0} introduced {1}"), this->GetName(), s->GetName()); } void Server::DelLink(Server *s) @@ -224,7 +224,7 @@ void Server::DelLink(Server *s) } } - Log(this, "quit") << "quit " << s->GetName(); + this->logger.Category("quit").Log(_("{0} quit {1}"), this->GetName(), s->GetName()); } void Server::Sync(bool sync_links) @@ -234,7 +234,7 @@ void Server::Sync(bool sync_links) syncing = false; - Log(this, "sync") << "is done syncing"; + this->logger.Category("sync").Log(_("{0} is done syncing"), this->GetName()); EventManager::Get()->Dispatch(&Event::ServerSync::OnServerSync, this); @@ -269,7 +269,7 @@ void Server::Sync(bool sync_links) if (!Anope::NoFork) { - Log(LOG_TERMINAL) << "Successfully linked, launching into background..."; + Anope::Logger.Terminal(_("Successfully linked, launching into background...")); Anope::Fork(); } } diff --git a/src/service_manager.cpp b/src/service_manager.cpp index 4c8d2a072..aa2de8b07 100644 --- a/src/service_manager.cpp +++ b/src/service_manager.cpp @@ -83,7 +83,7 @@ void ServiceManager::Register(Service *service) throw ModuleException("Service of type " + service->GetType() + " with name " + service->GetName() + " already exists from " + service->GetOwner()->name); } - Log(LOG_DEBUG_3) << "Service registered: " << service->GetType() << " " << service->GetName() << " address " << static_cast<void *>(this) << " by " << service->GetOwner(); + Anope::Logger.Debug3("Service registered: {0} {1} address {2} by {3}", service->GetType(), service->GetName(), static_cast<void *>(this), service->GetOwner()); services.push_back(service); @@ -92,7 +92,7 @@ void ServiceManager::Register(Service *service) void ServiceManager::Unregister(Service *service) { - Log(LOG_DEBUG_3) << "Service unregistered: " << service->GetType() << " " << service->GetName() << " address " << static_cast<void *>(service) << " by " << service->GetOwner(); + Anope::Logger.Debug3("Service unregistered: {0} {1} address {2} by {3}", service->GetType(), service->GetName(), static_cast<void *>(service), service->GetOwner()); auto it = std::find(services.begin(), services.end(), service); if (it != services.end()) @@ -108,13 +108,13 @@ void ServiceManager::Lookup(ServiceReferenceBase *reference) if (reference->GetName().empty()) { std::vector<Service *> services = this->FindServices(reference->GetType()); - Log(LOG_DEBUG_3) << "Service lookup " << static_cast<void *>(reference) << " type " << reference->GetType() << " name " << reference->GetName() << ": " << services.size() << " services"; + Anope::Logger.Debug3("Service lookup {0} type {1} name {2}: {3} services", static_cast<void *>(reference), reference->GetType(), reference->GetName(), services.size()); reference->SetServices(services); } else { Service *service = this->FindService(reference->GetType(), reference->GetName()); - Log(LOG_DEBUG_3) << "Service lookup " << static_cast<void *>(reference) << " type " << reference->GetType() << " name " << reference->GetName() << ": " << service; + Anope::Logger.Debug3("Service lookup {0} type {1} name {2}: {3}", static_cast<void *>(reference), reference->GetType(), reference->GetName(), service); reference->SetService(service); } } diff --git a/src/socket_clients.cpp b/src/socket_clients.cpp index 278ba7c21..5c45cdf51 100644 --- a/src/socket_clients.cpp +++ b/src/socket_clients.cpp @@ -42,7 +42,7 @@ bool ConnectionSocket::Process() } catch (const SocketException &ex) { - Log() << ex.GetReason(); + Anope::Logger.Log(ex.GetReason()); } return false; } @@ -62,7 +62,7 @@ void ConnectionSocket::OnConnect() void ConnectionSocket::OnError(const Anope::string &error) { - Log(LOG_DEBUG) << "Socket error: " << error; + Anope::Logger.Debug("Socket error: {0}", error); } ClientSocket::ClientSocket(ListenSocket *l, const sockaddrs &addr) : ls(l), clientaddr(addr) @@ -82,7 +82,7 @@ bool ClientSocket::Process() } catch (const SocketException &ex) { - Log() << ex.GetReason(); + Anope::Logger.Log(ex.GetReason()); } return false; } @@ -102,6 +102,6 @@ void ClientSocket::OnAccept() void ClientSocket::OnError(const Anope::string &error) { - Log(LOG_DEBUG) << "Socket error: " << error; + Anope::Logger.Debug("Socket error: {0}", error); } diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp index 3c0c22f40..314e1ec67 100644 --- a/src/socketengines/socketengine_epoll.cpp +++ b/src/socketengines/socketengine_epoll.cpp @@ -82,7 +82,7 @@ void SocketEngine::Process() if (total == -1) { if (errno != EINTR) - Log() << "SockEngine::Process(): error: " << Anope::LastError(); + Anope::Logger.Log("SocketEngine::Process(): error: {0}", Anope::LastError()); return; } diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp index 5c5c99afe..a3f6d78aa 100644 --- a/src/socketengines/socketengine_kqueue.cpp +++ b/src/socketengines/socketengine_kqueue.cpp @@ -83,7 +83,7 @@ void SocketEngine::Process() if (total == -1) { if (errno != EINTR) - Log() << "SockEngine::Process(): error: " << Anope::LastError(); + Anope::Logger.Log("SocketEngine::Process(): error: {0}", Anope::LastError()); return; } diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index 422959df2..c469ed8e8 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.cpp @@ -106,7 +106,7 @@ void SocketEngine::Process() if (total < 0) { if (errno != EINTR) - Log() << "SockEngine::Process(): error: " << Anope::LastError(); + Anope::Logger.Log("SocketEngine::Process(): error: {0}", Anope::LastError()); return; } diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp index f1f4fb8d8..7987010ec 100644 --- a/src/socketengines/socketengine_select.cpp +++ b/src/socketengines/socketengine_select.cpp @@ -107,7 +107,7 @@ void SocketEngine::Process() if (sresult == -1) { - Log() << "SockEngine::Process(): error: " << Anope::LastError(); + Anope::Logger.Log("SocketEngine::Process(): error: {0}", Anope::LastError()); } else if (sresult) { diff --git a/src/sockets.cpp b/src/sockets.cpp index 70c9fef0d..ecdddfbb2 100644 --- a/src/sockets.cpp +++ b/src/sockets.cpp @@ -552,7 +552,7 @@ bool ListenSocket::ProcessRead() } catch (const SocketException &ex) { - Log() << ex.GetReason(); + Anope::Logger.Log(ex.GetReason()); } return true; } diff --git a/src/uplink.cpp b/src/uplink.cpp index 1615eef9d..0f47788e7 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -42,7 +42,7 @@ class ReconnectTimer : public Timer } catch (const SocketException &ex) { - Log(LOG_TERMINAL) << "Unable to connect to uplink #" << (Anope::CurrentUplink + 1) << " (" << Config->Uplinks[Anope::CurrentUplink].host << ":" << Config->Uplinks[Anope::CurrentUplink].port << "): " << ex.GetReason(); + Anope::Logger.Terminal(_("Unable to connect to uplink #{0} ({1}:{2}): {3}"), Anope::CurrentUplink + 1, Config->Uplinks[Anope::CurrentUplink].host, Config->Uplinks[Anope::CurrentUplink].port, ex.GetReason()); } } }; @@ -51,7 +51,7 @@ void Uplink::Connect() { if (Config->Uplinks.empty()) { - Log() << "Warning: There are no configured uplinks."; + Anope::Logger.Log(_("Warning: There are no configured uplinks.")); return; } @@ -65,7 +65,7 @@ void Uplink::Connect() UplinkSock->Bind(Config->GetBlock("serverinfo")->Get<Anope::string>("localhost")); EventManager::Get()->Dispatch(&Event::PreServerConnect::OnPreServerConnect); Anope::string ip = Anope::Resolve(u.host, u.ipv6 ? AF_INET6 : AF_INET); - Log(LOG_TERMINAL) << "Attempting to connect to uplink #" << (Anope::CurrentUplink + 1) << " " << u.host << " (" << ip << "), port " << u.port; + Anope::Logger.Terminal(_("Attempting to connect to uplink #{0} {1} ({2}), port {3}"), Anope::CurrentUplink + 1, u.host, ip, u.port); UplinkSock->Connect(ip, u.port); } @@ -82,9 +82,9 @@ UplinkSocket::~UplinkSocket() this->OnError(""); Module *protocol = ModuleManager::FindFirstOf(PROTOCOL); if (protocol && !protocol->name.find("inspircd")) - Log(LOG_TERMINAL) << "Check that you have loaded m_spanningtree.so on InspIRCd, and are not connecting Anope to an SSL enabled port without configuring SSL in Anope (or vice versa)"; + Anope::Logger.Terminal(_("Check that you have loaded m_spanningtree.so on InspIRCd, and are not connecting Anope to an SSL enabled port without configuring SSL in Anope (or vice versa)")); else - Log(LOG_TERMINAL) << "Check that you are not connecting Anope to an SSL enabled port without configuring SSL in Anope (or vice versa)"; + Anope::Logger.Terminal(_("Check that you are not connecting Anope to an SSL enabled port without configuring SSL in Anope (or vice versa)")); } if (IRCD && Servers::GetUplink() && Servers::GetUplink()->IsSynced()) @@ -135,7 +135,7 @@ UplinkSocket::~UplinkSocket() { time_t retry = Config->GetBlock("options")->Get<time_t>("retrywait"); - Log() << "Disconnected, retrying in " << retry << " seconds"; + Anope::Logger.Log(_("Disconnected, retrying in {0} seconds"), retry); new ReconnectTimer(retry); } } @@ -154,15 +154,17 @@ bool UplinkSocket::ProcessRead() void UplinkSocket::OnConnect() { - Log(LOG_TERMINAL) << "Successfully connected to uplink #" << (Anope::CurrentUplink + 1) << " " << Config->Uplinks[Anope::CurrentUplink].host << ":" << Config->Uplinks[Anope::CurrentUplink].port; + Anope::Logger.Terminal(_("Successfully connected to uplink #{0} {1}:{2}"), Anope::CurrentUplink + 1, Config->Uplinks[Anope::CurrentUplink].host, Config->Uplinks[Anope::CurrentUplink].port); IRCD->Handshake(); EventManager::Get()->Dispatch(&Event::ServerConnect::OnServerConnect); } void UplinkSocket::OnError(const Anope::string &err) { - Anope::string what = !this->flags[SF_CONNECTED] ? "Unable to connect to" : "Lost connection from"; - Log(LOG_TERMINAL) << what << " uplink #" << (Anope::CurrentUplink + 1) << " (" << Config->Uplinks[Anope::CurrentUplink].host << ":" << Config->Uplinks[Anope::CurrentUplink].port << ")" << (!err.empty() ? (": " + err) : ""); + if (!this->flags[SF_CONNECTED]) + Anope::Logger.Terminal(_("Unable to connect to uplink #{0} ({1}:{2}): {3}{4}"), Anope::CurrentUplink + 1, Config->Uplinks[Anope::CurrentUplink].host, Config->Uplinks[Anope::CurrentUplink].port, !err.empty() ? (": " + err) : ""); + else + Anope::Logger.Terminal(_("Lost connection from uplink #{0} ({1}:{2}): {3}{4}"), Anope::CurrentUplink + 1, Config->Uplinks[Anope::CurrentUplink].host, Config->Uplinks[Anope::CurrentUplink].port, !err.empty() ? (": " + err) : ""); error |= !err.empty(); } @@ -177,7 +179,7 @@ void Uplink::SendMessage(IRCMessage &message) if (s != Me && !s->IsJuped()) { - Log(LOG_DEBUG) << "Attempted to send \"" << buffer << "\" from " << s->GetName() << " who is not from me?"; + Anope::Logger.Debug("Attempted to send \"{0}\" from {1} who is not from me?", buffer, s->GetName()); return; } } @@ -187,24 +189,24 @@ void Uplink::SendMessage(IRCMessage &message) if (u->server != Me && !u->server->IsJuped()) { - Log(LOG_DEBUG) << "Attempted to send \"" << buffer << "\" from " << u->nick << " who is not from me?"; + Anope::Logger.Debug("Attempted to send \"{0}\" from {1} who is not from me?", buffer, u->nick); return; } const ServiceBot *bi = source.GetBot(); if (bi != NULL && bi->introduced == false) { - Log(LOG_DEBUG) << "Attempted to send \"" << buffer << "\" from " << bi->nick << " when not introduced"; + Anope::Logger.Debug("Attempted to send \"{0}\" from {1} when not introduced", buffer, bi->nick); return; } } if (!UplinkSock) { - Log(LOG_DEBUG) << "Attempted to send \"" << buffer << "\" with UplinkSock NULL"; + Anope::Logger.Debug("Attempted to send \"{0}\" when not connected", buffer); return; } UplinkSock->Write(buffer); - Log(LOG_RAWIO) << "Sent: " << buffer; + Anope::Logger.RawIO("Sent: {0}", buffer); } diff --git a/src/users.cpp b/src/users.cpp index a9bb432b5..018f88476 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -40,7 +40,7 @@ int OperCount = 0; std::list<User *> User::quitting_users; -User::User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &uip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickServ::Account *account) : ip(uip) +User::User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &svhost, const Anope::string &uip, Server *sserver, const Anope::string &srealname, time_t ts, const Anope::string &smodes, const Anope::string &suid, NickServ::Account *account) : ip(uip), logger(this) { if (snick.empty() || sident.empty() || shost.empty()) throw CoreException("Bad args passed to User::User"); @@ -68,7 +68,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope: if (!suid.empty()) UserListByUID[suid] = this; if (old == UserListByNick.size()) - Log(LOG_DEBUG) << "Duplicate user " << snick << " in user table?"; + Anope::Logger.Debug("Duplicate user {0} in user table?", snick); this->Login(account); this->UpdateHost(); @@ -77,7 +77,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope: { ++sserver->users; if (server->IsSynced()) - Log(this, "connect") << (!vhost.empty() && vhost != host ? "(" + vhost + ") " : "") << "(" << srealname << ") " << (!uip.empty() && uip != host ? "[" + uip + "] " : "") << "connected to the network (" << sserver->GetName() << ")"; + logger.Category("connect").Log(_("{0} ({1}) ({2}) [{3}] connected to the network ({4})"), this->GetMask(), vhost.empty() ? host : vhost, srealname, uip.empty() ? host : uip, sserver->GetName()); } bool exempt = false; @@ -143,7 +143,7 @@ void User::ChangeNick(const Anope::string &newnick, time_t ts) throw CoreException("User::ChangeNick() got a bad argument"); this->super_admin = false; - Log(this, "nick") << "(" << this->realname << ") changed nick to " << newnick; + logger.Category("nick").Log(_("{0} ({1}) changed nick to {2}"), this->GetMask(), this->realname, newnick); Anope::string old = this->nick; this->timestamp = ts; @@ -196,7 +196,7 @@ void User::SetDisplayedHost(const Anope::string &shost) this->vhost = shost; - Log(this, "host") << "changed vhost to " << shost; + logger.Category("host").Log(_("{0} changed vhost to {1}"), this->GetMask(), shost); EventManager::Get()->Dispatch(&Event::SetDisplayedHost::OnSetDisplayedHost, this); @@ -220,7 +220,7 @@ void User::SetCloakedHost(const Anope::string &newhost) chost = newhost; - Log(this, "host") << "changed cloaked host to " << newhost; + logger.Category("host").Log(_("{0} changed cloaked host to {1}"), this->GetMask(), newhost); this->UpdateHost(); } @@ -242,7 +242,7 @@ void User::SetVIdent(const Anope::string &sident) { this->vident = sident; - Log(this, "ident") << "changed vident to " << sident; + logger.Category("ident").Log(_("{0} changed vident to {1}"), this->GetMask(), sident); this->UpdateHost(); } @@ -259,7 +259,7 @@ void User::SetIdent(const Anope::string &sident) { this->ident = sident; - Log(this, "ident") << "changed real ident to " << sident; + logger.Category("ident").Log(_("{0} changed real ident to {1}"), this->GetMask(), sident); this->UpdateHost(); } @@ -292,7 +292,7 @@ void User::SetRealname(const Anope::string &srealname) if (na && (this->IsIdentified(true) || this->IsRecognized())) na->SetLastRealname(srealname); - Log(this, "realname") << "changed realname to " << srealname; + logger.Category("realname").Log(_("{0} changed realname to {1}"), this->GetMask(), srealname); } User::~User() @@ -300,7 +300,7 @@ User::~User() if (this->server != NULL) { if (this->server->IsSynced()) - Log(this, "disconnect") << "(" << this->realname << ") disconnected from the network (" << this->server->GetName() << ")"; + logger.Category("disconnect").Log(_("{0} ({1}) disconnected from the network ({2})"), this->GetMask(), this->realname, this->server->GetName()); --this->server->users; } @@ -421,7 +421,7 @@ void User::Login(NickServ::Account *core) this->UpdateHost(); if (this->server->IsSynced()) - Log(this, "account") << "is now identified as " << this->nc->GetDisplay(); + logger.Category("account").Log(_("{0} is now identified as {1}"), this->GetMask(), this->nc->GetDisplay()); EventManager::Get()->Dispatch(&Event::UserLogin::OnUserLogin, this); } @@ -431,7 +431,7 @@ void User::Logout() if (!this->nc) return; - Log(this, "account") << "is no longer identified as " << this->nc->GetDisplay(); + logger.Category("account").Log(_("{0} is no longer identified as {1}"), this->GetMask(), this->nc->GetDisplay()); auto it = std::find(this->nc->users.begin(), this->nc->users.end(), this); if (it != this->nc->users.end()) @@ -687,7 +687,7 @@ void User::SetModesInternal(const MessageSource &source, const char *umodes, ... va_end(args); if (this->server && this->server->IsSynced() && Anope::string(buf) != "+") - Log(this, "mode") << "changes modes to " << buf; + logger.Category("mode").Log(_("{0} changes mode to {1}"), this->GetMask(), buf); spacesepstream sep(buf); sep.GetToken(modebuf); @@ -771,11 +771,11 @@ void User::KillInternal(const MessageSource &source, const Anope::string &reason { if (this->quit) { - Log(LOG_DEBUG) << "Duplicate quit for " << this->nick; + Anope::Logger.Debug("Duplicate quit for {0}", this->nick); return; } - Log(this, "killed") << "was killed by " << source.GetName() << " (Reason: " << reason << ")"; + logger.Category("killed").Log(_("{0} was killed by {1} (Reason: {2})"), this->GetMask(), source.GetName(), reason); this->Quit(reason); } @@ -784,7 +784,7 @@ void User::Quit(const Anope::string &reason) { if (this->quit) { - Log(LOG_DEBUG) << "Duplicate quit for " << this->nick; + Anope::Logger.Debug("Duplicate quit for {0}", this->nick); return; } @@ -799,7 +799,7 @@ bool User::Quitting() const return this->quit; } -Anope::string User::Mask() const +Anope::string User::WildMask() const { Anope::string mask; const Anope::string &mident = this->GetIdent(); @@ -813,7 +813,7 @@ Anope::string User::Mask() const sockaddrs addr(mhost); if (addr.valid() && addr.sa.sa_family == AF_INET) { - size_t dot = mhost.find('.'); + size_t dot = mhost.rfind('.'); mask += mhost.substr(0, dot) + (dot == Anope::string::npos ? "" : ".*"); } else diff --git a/src/xline.cpp b/src/xline.cpp index 7d26461b4..8fa7085c8 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -48,7 +48,7 @@ void XLine::Recache() } catch (const std::regex_error &ex) { - Log(LOG_DEBUG) << ex.what(); + Anope::Logger.Debug(ex.what()); } } |