diff options
author | Adam <Adam@anope.org> | 2014-05-20 12:19:26 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-05-20 12:19:26 -0400 |
commit | 20ce170024779aebbc1462146905c976836a552f (patch) | |
tree | 45a604b3f717e121af846ea586888f4a3fa3f085 /src/logger.cpp | |
parent | 4034b3054aaff28da1db5545063cf8b3c2e8aa24 (diff) |
Show account names in log messages
Diffstat (limited to 'src/logger.cpp')
-rw-r--r-- | src/logger.cpp | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/src/logger.cpp b/src/logger.cpp index 445e71949..2b6d06e87 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -137,6 +137,27 @@ Log::~Log() Config->LogInfos[i].ProcessMessage(this); } +Anope::string Log::FormatSource() const +{ + if (u) + if (nc) + return this->u->GetMask() + " (" + this->nc->display + ")"; + else + return this->u->GetMask(); + else if (nc) + return nc->display; + return ""; +} + +Anope::string Log::FormatCommand() const +{ + Anope::string buffer = FormatSource() + " used " + (source != NULL && !source->command.empty() ? source->command : this->c->name) + " "; + if (this->ci) + buffer += "on " + this->ci->name + " "; + + return buffer; +} + Anope::string Log::BuildPrefix() const { Anope::string buffer; @@ -147,61 +168,34 @@ Anope::string Log::BuildPrefix() const { if (!this->c) break; - buffer += "ADMIN: "; - Anope::string cname = source != NULL && !source->command.empty() ? source->command : this->c->name; - if (this->u) - buffer += this->u->GetMask() + " used " + cname + " "; - else if (this->nc) - buffer += this->nc->display + " used " + cname + " "; - if (this->ci) - buffer += "on " + this->ci->name + " "; + buffer += "ADMIN: " + FormatCommand(); break; } case LOG_OVERRIDE: { if (!this->c) break; - buffer += "OVERRIDE: "; - Anope::string cname = source != NULL && !source->command.empty() ? source->command : this->c->name; - if (this->u) - buffer += this->u->GetMask() + " used " + cname + " "; - else if (this->nc) - buffer += this->nc->display + " used " + cname + " "; - if (this->ci) - buffer += "on " + this->ci->name + " "; + buffer += "OVERRIDE: " + FormatCommand(); break; } case LOG_COMMAND: { if (!this->c) break; - buffer += "COMMAND: "; - Anope::string cname = source != NULL && !source->command.empty() ? source->command : this->c->name; - if (this->u) - buffer += this->u->GetMask() + " used " + cname + " "; - else if (this->source) - buffer += this->source->GetNick() + " used " + cname + " "; - else if (this->nc) - buffer += this->nc->display + " used " + cname + " "; - if (this->ci) - buffer += "on " + this->ci->name + " "; + buffer += "COMMAND: " + FormatCommand(); break; } case LOG_CHANNEL: { if (!this->chan) break; - buffer += "CHANNEL: "; - if (this->u) - buffer += this->u->GetMask() + " " + this->category + " " + this->chan->name + " "; - else - buffer += this->category + " " + this->chan->name + " "; + buffer += "CHANNEL: " + FormatSource() + " " + this->category + " " + this->chan->name + " "; break; } case LOG_USER: { if (this->u) - buffer += "USERS: " + this->u->GetMask() + " "; + buffer += "USERS: " + FormatSource() + " "; break; } case LOG_SERVER: |