diff options
author | Adam <Adam@anope.org> | 2017-02-06 14:23:18 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2017-02-06 14:23:18 -0500 |
commit | 8b694bc392c36551e428b84454efb81cdbc8bcd3 (patch) | |
tree | ca3d1ca8aadac280c149518134de4208f91dad84 /include | |
parent | 9ad06f49bbb3824139b0c0ee0a74898a18c8f735 (diff) |
Track override in CommandSource and use it in the logger
Diffstat (limited to 'include')
-rw-r--r-- | include/commands.h | 8 | ||||
-rw-r--r-- | include/logger.h | 29 |
2 files changed, 35 insertions, 2 deletions
diff --git a/include/commands.h b/include/commands.h index d3aa180a2..1dddfa4fd 100644 --- a/include/commands.h +++ b/include/commands.h @@ -67,6 +67,8 @@ class CoreExport CommandSource Reference<User> u; /* Command info being executed */ CommandInfo command; + /* whether or not this is an override as determined by the command */ + bool override = false; public: /* The account executing the command */ Reference<NickServ::Account> nc; @@ -108,6 +110,10 @@ class CoreExport CommandSource bool HasPriv(const Anope::string &cmd); bool IsServicesOper(); bool IsOper(); + + bool HasOverridePriv(const Anope::string &priv); + bool HasOverrideCommand(const Anope::string &priv); + bool IsOverride() const; }; /** Every services command is a class, inheriting from Command. @@ -143,8 +149,6 @@ class CoreExport Command : public Service */ Command(Module *owner, const Anope::string &sname, size_t min_params, size_t max_params = 0); - virtual ~Command(); - void SetDesc(const Anope::string &d); void ClearSyntax(); diff --git a/include/logger.h b/include/logger.h index d368eb142..eabc9d878 100644 --- a/include/logger.h +++ b/include/logger.h @@ -120,6 +120,7 @@ class Logger Anope::string BuildPrefix() const; void LogMessage(const Anope::string &message); void InsertVariables(FormatInfo &fi); + void CheckOverride(); template<typename... Args> Anope::string Format(const Anope::string &message, Args&&... args) @@ -184,9 +185,13 @@ class Logger template<typename... Args> void Command(LogType type, CommandSource &source, ChanServ::Channel *ci, const Anope::string &message, Args&&... args) { Logger l = *this; + l.type = type; l.SetSource(&source); l.SetCi(ci); + // Override if the source is marked override + l.CheckOverride(); + Anope::string translated = Language::Translate(message); l.LogMessage(l.Format(translated, std::forward<Args>(args)...)); } @@ -196,6 +201,30 @@ class Logger Command(type, source, nullptr, message, std::forward<Args>(args)...); } + // LOG_COMMAND + + template<typename... Args> void Command(CommandSource &source, ChanServ::Channel *ci, const Anope::string &message, Args&&... args) + { + Command(LogType::COMMAND, source, ci, message, std::forward<Args>(args)...); + } + + template<typename... Args> void Command(CommandSource &source, const Anope::string &message, Args&&... args) + { + Command(LogType::COMMAND, source, nullptr, message, std::forward<Args>(args)...); + } + + // LOG_ADMIN + + template<typename... Args> void Admin(CommandSource &source, ChanServ::Channel *ci, const Anope::string &message, Args&&... args) + { + Command(LogType::ADMIN, source, ci, message, std::forward<Args>(args)...); + } + + template<typename... Args> void Admin(CommandSource &source, const Anope::string &message, Args&&... args) + { + Command(LogType::ADMIN, source, nullptr, message, std::forward<Args>(args)...); + } + template<typename... Args> void Log(const Anope::string &message, Args&&... args) { Log(LogLevel::NORMAL, message, std::forward<Args>(args)...); |