diff options
author | Adam <Adam@anope.org> | 2014-06-23 09:45:15 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-06-23 09:45:15 -0400 |
commit | fd9bb0ea7e3c8a39f1632c2ebbdc25d0fac192a0 (patch) | |
tree | 1d68e86065e0b012aee41533d4f9b289ee0707ac /src/logger.cpp | |
parent | 148b26f687ce85dc01e852a2358b03d493757ada (diff) | |
parent | 9a947fa4359c667be58ebae4634d9ac0e53d5db4 (diff) |
Merge branch '2.0' into 2.1
Conflicts:
cmake/Anope.cmake
cmake/FindGettext.cmake
include/access.h
include/messages.h
include/modes.h
include/modules.h
include/users.h
modules/CMakeLists.txt
modules/commands/bs_bot.cpp
modules/commands/cs_access.cpp
modules/commands/cs_ban.cpp
modules/commands/cs_clone.cpp
modules/commands/cs_flags.cpp
modules/commands/cs_info.cpp
modules/commands/cs_list.cpp
modules/commands/cs_log.cpp
modules/commands/cs_mode.cpp
modules/commands/cs_status.cpp
modules/commands/cs_suspend.cpp
modules/commands/cs_updown.cpp
modules/commands/cs_xop.cpp
modules/commands/ms_check.cpp
modules/commands/ns_access.cpp
modules/commands/ns_cert.cpp
modules/commands/ns_group.cpp
modules/commands/ns_register.cpp
modules/commands/ns_set.cpp
modules/commands/ns_suspend.cpp
modules/commands/os_session.cpp
modules/commands/os_svs.cpp
modules/extra/m_ldap_authentication.cpp
modules/extra/m_regex_pcre.cpp
modules/extra/m_sql_authentication.cpp
modules/extra/stats/m_chanstats.cpp
modules/protocol/bahamut.cpp
modules/protocol/hybrid.cpp
modules/protocol/inspircd12.cpp
modules/protocol/inspircd20.cpp
modules/protocol/unreal.cpp
modules/pseudoclients/chanserv.cpp
modules/pseudoclients/chanserv/channel.cpp
modules/pseudoclients/nickserv/nickserv.cpp
modules/webcpanel/pages/chanserv/access.cpp
src/access.cpp
src/bots.cpp
src/channels.cpp
src/language.cpp
src/modes.cpp
src/modulemanager.cpp
src/process.cpp
src/users.cpp
src/version.sh
Diffstat (limited to 'src/logger.cpp')
-rw-r--r-- | src/logger.cpp | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/src/logger.cpp b/src/logger.cpp index 86141ed8a..9dad74a67 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -93,7 +93,7 @@ Log::Log(LogType t, CommandSource &src, Command *_c, ChanServ::Channel *_ci) : u size_t sl = c->name.find('/'); this->bi = NULL; if (sl != Anope::string::npos) - this->bi = BotInfo::Find(c->name.substr(0, sl)); + this->bi = BotInfo::Find(c->name.substr(0, sl), true); this->category = c->name; } @@ -140,6 +140,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; @@ -150,44 +171,21 @@ 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: @@ -195,16 +193,16 @@ Anope::string Log::BuildPrefix() const 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 + " "; + Anope::string src = FormatSource(); + if (!src.empty()) + buffer += src + " "; + buffer += this->category + " " + this->chan->name + " "; break; } case LOG_USER: { if (this->u) - buffer += "USERS: " + this->u->GetMask() + " "; + buffer += "USERS: " + FormatSource() + " "; break; } case LOG_SERVER: |