diff options
author | Adam <Adam@anope.org> | 2017-10-22 17:16:32 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2017-10-22 17:16:32 -0400 |
commit | 14235cf938f1b93211f2d7538c3d3a39a64341e5 (patch) | |
tree | af5ebc03c200697baef268a5a99f4073c47b7fdf /include | |
parent | 6d79b0944026c8a8bb28ab47a53d70fb423f5aac (diff) |
Store full and masked message in logger for chanserv/log
Diffstat (limited to 'include')
-rw-r--r-- | include/event.h | 4 | ||||
-rw-r--r-- | include/logger.h | 27 |
2 files changed, 22 insertions, 9 deletions
diff --git a/include/event.h b/include/event.h index 985eb6ef7..0dc200c7e 100644 --- a/include/event.h +++ b/include/event.h @@ -1083,9 +1083,9 @@ namespace Event using Events::Events; /** Called when a message is logged - * @param l The log message + * @param logger The logger */ - virtual void OnLog(Logger *l) anope_abstract; + virtual void OnLog(Logger *logger) anope_abstract; }; struct CoreExport LogMessage : Events diff --git a/include/logger.h b/include/logger.h index 933a753af..64800ccee 100644 --- a/include/logger.h +++ b/include/logger.h @@ -108,6 +108,10 @@ class Logger Anope::string category; /* Non formatted message */ Anope::string raw_message; + /* Message */ + Anope::string full_message; + /* Masked message */ + Anope::string masked_message; /* Sources */ User *user = nullptr; @@ -116,18 +120,18 @@ class Logger ChanServ::Channel *ci = nullptr; CommandSource *source = nullptr; - Anope::string FormatSource() const; + Anope::string FormatSource(bool full) const; Anope::string BuildPrefix() const; - void LogMessage(const Anope::string &message); - void InsertVariables(FormatInfo &fi); + void LogMessage(); + void InsertVariables(FormatInfo &fi, bool full); void CheckOverride(); template<typename... Args> - Anope::string Format(const Anope::string &message, Args&&... args) + Anope::string Format(const Anope::string &message, bool full, Args&&... args) { FormatInfo fi(message, sizeof...(Args)); fi.AddArgs(std::forward<Args>(args)...); - InsertVariables(fi); + InsertVariables(fi, full); fi.Format(); return fi.GetFormat(); } @@ -164,6 +168,10 @@ class Logger CommandSource *GetSource() const; void SetSource(CommandSource *); + const Anope::string &GetUnformattedMessage() const; + const Anope::string &GetMessage() const; + const Anope::string &GetMaskedMessage() const; + Logger Category(const Anope::string &c) const; Logger User(class User *u) const; Logger Channel(class Channel *c) const; @@ -179,12 +187,15 @@ class Logger l.level = lev; Anope::string translated = Language::Translate(message); - l.LogMessage(l.Format(translated, std::forward<Args>(args)...)); + l.full_message = l.Format(translated, true, std::forward<Args>(args)...); + l.masked_message = l.Format(translated, false, std::forward<Args>(args)...); + l.LogMessage(); } template<typename... Args> void Command(LogType ltype, CommandSource &csource, ChanServ::Channel *chan, const Anope::string &message, Args&&... args) { Logger l = *this; + l.raw_message = message; l.type = ltype; l.SetSource(&csource); l.SetCi(chan); @@ -193,7 +204,9 @@ class Logger l.CheckOverride(); Anope::string translated = Language::Translate(message); - l.LogMessage(l.Format(translated, std::forward<Args>(args)...)); + l.full_message = l.Format(translated, true, std::forward<Args>(args)...); + l.masked_message = l.Format(translated, false, std::forward<Args>(args)...); + l.LogMessage(); } template<typename... Args> void Command(LogType ltype, CommandSource &csource, const Anope::string &message, Args&&... args) |