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 /include | |
parent | ff030c1eb7c3764f9add2a689479e84d616cabcb (diff) |
Make log system use newer format strings
Also allow log messages to be translatable
Diffstat (limited to 'include')
-rw-r--r-- | include/anope.h | 51 | ||||
-rw-r--r-- | include/bots.h | 5 | ||||
-rw-r--r-- | include/channels.h | 25 | ||||
-rw-r--r-- | include/commands.h | 15 | ||||
-rw-r--r-- | include/defs.h | 1 | ||||
-rw-r--r-- | include/event.h | 4 | ||||
-rw-r--r-- | include/extensible.h | 6 | ||||
-rw-r--r-- | include/logger.h | 243 | ||||
-rw-r--r-- | include/modules.h | 4 | ||||
-rw-r--r-- | include/modules/dns.h | 2 | ||||
-rw-r--r-- | include/modules/redis.h | 6 | ||||
-rw-r--r-- | include/protocol.h | 3 | ||||
-rw-r--r-- | include/serialize.h | 17 | ||||
-rw-r--r-- | include/servers.h | 6 | ||||
-rw-r--r-- | include/users.h | 11 |
15 files changed, 258 insertions, 141 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. |