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 /src | |
parent | 6d79b0944026c8a8bb28ab47a53d70fb423f5aac (diff) |
Store full and masked message in logger for chanserv/log
Diffstat (limited to 'src')
-rw-r--r-- | src/logger.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/logger.cpp b/src/logger.cpp index adb880065..78455e260 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -285,7 +285,7 @@ void LogInfo::ProcessMessage(const Logger *l, const Anope::string &message) } } -void Logger::InsertVariables(FormatInfo &fi) +void Logger::InsertVariables(FormatInfo &fi, bool full) { if (user != nullptr) fi.Add("user"_kw = user->GetMask()); @@ -295,7 +295,7 @@ void Logger::InsertVariables(FormatInfo &fi) else if (channel != nullptr) fi.Add("channel"_kw = channel->GetName()); - fi.Add("source"_kw = this->FormatSource()); + fi.Add("source"_kw = this->FormatSource(full)); if (source != nullptr && !source->GetCommand().empty()) fi.Add("command"_kw = source->GetCommand()); @@ -309,13 +309,17 @@ void Logger::CheckOverride() type = LogType::OVERRIDE; } -Anope::string Logger::FormatSource() const +Anope::string Logger::FormatSource(bool full) const { if (user) + { + const Anope::string &umask = full ? user->GetMask() : user->GetDisplayedMask(); + if (account) - return user->GetMask() + " (" + account->GetDisplay() + ")"; + return umask + " (" + account->GetDisplay() + ")"; else - return user->GetMask(); + return umask; + } else if (account) return account->GetDisplay(); else if (source) @@ -348,14 +352,14 @@ Anope::string Logger::BuildPrefix() const return ""; } -void Logger::LogMessage(const Anope::string &message) +void Logger::LogMessage() { 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; + std::cout << GetTimeStamp() << " Debug: " << this->BuildPrefix() << full_message << std::endl; else if (Anope::NoFork && level <= LogLevel::TERMINAL) - std::cout << GetTimeStamp() << " " << this->BuildPrefix() << message << std::endl; + std::cout << GetTimeStamp() << " " << this->BuildPrefix() << full_message << std::endl; else if (level == LogLevel::TERMINAL) - std::cout << this->BuildPrefix() << message << std::endl; + std::cout << this->BuildPrefix() << full_message << std::endl; if (level <= LogLevel::NORMAL) { @@ -367,7 +371,7 @@ void Logger::LogMessage(const Anope::string &message) if (Config != nullptr) for (LogInfo &info : Config->LogInfos) if (info.HasType(this->type, this->level, this->category)) - info.ProcessMessage(this, message); + info.ProcessMessage(this, full_message); } LogType Logger::GetType() const @@ -456,6 +460,21 @@ void Logger::SetSource(CommandSource *s) } } +const Anope::string &Logger::GetUnformattedMessage() const +{ + return raw_message; +} + +const Anope::string &Logger::GetMessage() const +{ + return full_message; +} + +const Anope::string &Logger::GetMaskedMessage() const +{ + return masked_message; +} + Logger Logger::Category(const Anope::string &c) const { Logger l = *this; |