From 16ca76c2e7ab287e480185fbb03a0bb438351eda Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 23 Jan 2017 12:35:14 -0500 Subject: Make log system use newer format strings Also allow log messages to be translatable --- modules/chanserv/access.cpp | 15 +++---- modules/chanserv/akick.cpp | 36 ++++++++++------ modules/chanserv/ban.cpp | 4 +- modules/chanserv/clone.cpp | 3 +- modules/chanserv/drop.cpp | 3 +- modules/chanserv/enforce.cpp | 12 +++--- modules/chanserv/entrymsg.cpp | 13 ++++-- modules/chanserv/flags.cpp | 18 +++++--- modules/chanserv/getkey.cpp | 2 +- modules/chanserv/invite.cpp | 4 +- modules/chanserv/kick.cpp | 4 +- modules/chanserv/list.cpp | 6 ++- modules/chanserv/log.cpp | 32 ++++++++++---- modules/chanserv/main/channel.cpp | 10 ++--- modules/chanserv/main/chanserv.cpp | 20 ++++++--- modules/chanserv/mode.cpp | 12 ++++-- modules/chanserv/register.cpp | 3 +- modules/chanserv/seen.cpp | 8 ++-- modules/chanserv/set.cpp | 85 +++++++++++++++++++++++++------------- modules/chanserv/set_misc.cpp | 8 +++- modules/chanserv/suspend.cpp | 11 +++-- modules/chanserv/sync.cpp | 2 +- modules/chanserv/topic.cpp | 11 +++-- modules/chanserv/unban.cpp | 10 ++--- modules/chanserv/updown.cpp | 11 +++-- modules/chanserv/xop.cpp | 46 ++++++++++----------- 26 files changed, 242 insertions(+), 147 deletions(-) (limited to 'modules/chanserv') diff --git a/modules/chanserv/access.cpp b/modules/chanserv/access.cpp index 967df9025..6ad67733e 100644 --- a/modules/chanserv/access.cpp +++ b/modules/chanserv/access.cpp @@ -213,7 +213,8 @@ class CommandCSAccess : public Command EventManager::Get()->Dispatch(&Event::AccessAdd::OnAccessAdd, ci, source, access); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << " with level " << level; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0} with level {1}"), mask, level); + if (p != NULL) source.Reply(_("\002{0}\002 added to the access list of \002{1}\002 with privilege \002{2}\002 (level \002{3}\002)."), access->Mask(), ci->GetName(), p->name, level); else @@ -283,7 +284,7 @@ class CommandCSAccess : public Command source.Reply(_("There are no entries matching \002{0}\002 on the access list of \002{1}\002."), mask, ci->GetName()); else { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << nicks; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), mask); if (deleted == 1) source.Reply(_("Deleted \0021\002 entry from the access list of \002{0}\002."), ci->GetName()); @@ -308,7 +309,7 @@ class CommandCSAccess : public Command { source.Reply(_("\002{0}\002 deleted from the access list of \002{1}\002."), access->Mask(), ci->GetName()); bool override = !u_access.founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->Mask().equals_ci(source.nc->GetDisplay()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->Mask(); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {3}"), access->Mask()); EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, access); delete access; @@ -458,7 +459,7 @@ class CommandCSAccess : public Command source.Reply(_("The access list of \002{0}\002 has been cleared."), ci->GetName()); bool override = !source.IsFounder(ci); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the access list")); } public: @@ -672,7 +673,7 @@ class CommandCSLevels : public Command else { bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << p->name << " to level " << level; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to set {0} to level {1}"), p->name, level); ci->SetLevel(p->name, level); EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, p->name, level); @@ -699,7 +700,7 @@ class CommandCSLevels : public Command if (p != NULL) { bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable " << p->name; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable {0}"), p->name); ci->SetLevel(p->name, ChanServ::ACCESS_INVALID); EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, p->name, ChanServ::ACCESS_INVALID); @@ -754,7 +755,7 @@ class CommandCSLevels : public Command void DoReset(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to reset all levels"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to reset all levels")); ci->ClearLevels(); EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, "ALL", 0); diff --git a/modules/chanserv/akick.cpp b/modules/chanserv/akick.cpp index 9338a4dd7..35bca6818 100644 --- a/modules/chanserv/akick.cpp +++ b/modules/chanserv/akick.cpp @@ -302,7 +302,10 @@ class CommandCSAKick : public Command else ak = ci->AddAkick(source.GetNick(), mask, reason); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason; + if (reason.empty()) + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0}"), mask); + else + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0} ({1})"), mask, reason); EventManager::Get()->Dispatch(&Event::Akick::OnAkickAdd, source, ci, ak); @@ -337,10 +340,11 @@ class CommandCSAKick : public Command EventManager::Get()->Dispatch(&Event::Akick::OnAkickDel, source, ci, ak); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << (ak->GetAccount() ? ak->GetAccount()->GetDisplay() : ak->GetMask()); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), + ak->GetAccount() ? ak->GetAccount()->GetDisplay() : ak->GetMask()); ++deleted; - delete ak; + ak->Delete(); }, [&]() { @@ -357,29 +361,33 @@ class CommandCSAKick : public Command { NickServ::Nick *na = NickServ::FindNick(mask); NickServ::Account *nc = na ? na->GetAccount() : nullptr; + AutoKick *match = nullptr; - unsigned int i, end; - for (i = 0, end = ci->GetAkickCount(); i < end; ++i) + for (unsigned int i = 0; i < ci->GetAkickCount(); ++i) { AutoKick *ak = ci->GetAkick(i); if (ak->GetAccount() ? ak->GetAccount() == nc : mask.equals_ci(ak->GetMask())) + { + match = ak; break; + } } - if (i == ci->GetAkickCount()) + if (match == nullptr) { source.Reply(_("\002{0}\002 was not found on the auto kick list of \002{1}\002."), mask, ci->GetName()); return; } - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), + match->GetAccount() ? match->GetAccount()->GetDisplay() : match->GetMask()); - EventManager::Get()->Dispatch(&Event::Akick::OnAkickDel, source, ci, ci->GetAkick(i)); + EventManager::Get()->Dispatch(&Event::Akick::OnAkickDel, source, ci, match); - delete ci->GetAkick(i); + source.Reply(_("\002{0}\002 deleted from the auto kick list of \002{1}\002."), match->GetAccount() ? match->GetAccount()->GetDisplay() : match->GetMask(), ci->GetName()); - source.Reply(_("\002{0}\002 deleted from the auto kick list of \002{1}\002."), mask, ci->GetName()); + match->Delete(); } } @@ -523,7 +531,8 @@ class CommandCSAKick : public Command } bool override = !source.AccessFor(ci).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ENFORCE, affects " << count << " users"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, + _("{source} used {command} on {channel} to enforce the akick list, affects {0} users"), count); source.Reply(_("Autokick enforce for \002{0}\002 complete; \002{1}\002 users were affected."), ci->GetName(), count); } @@ -531,7 +540,7 @@ class CommandCSAKick : public Command void DoClear(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the akick list"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the akick list")); ci->ClearAkick(); source.Reply(_("The autokick list of \002{0}\002 has been cleared."), ci->GetName()); @@ -712,7 +721,8 @@ class CSAKick : public Module if (kick) { - Log(LOG_DEBUG_2) << u->nick << " matched akick " << (ak->GetAccount() ? ak->GetAccount()->GetDisplay() : ak->GetMask()); + logger.Debug2("{0} matched akick {1}", u->nick, ak->GetAccount() ? ak->GetAccount()->GetDisplay() : ak->GetMask()); + ak->SetLastUsed(Anope::CurTime); if (!ak->GetAccount() && ak->GetMask().find('#') == Anope::string::npos) mask = ak->GetMask(); diff --git a/modules/chanserv/ban.cpp b/modules/chanserv/ban.cpp index 2b73df8fb..d79afe071 100644 --- a/modules/chanserv/ban.cpp +++ b/modules/chanserv/ban.cpp @@ -152,7 +152,7 @@ class CommandCSBan : public Command Anope::string mask = ci->GetIdealBan(u2); bool override = !u_access.HasPriv("BAN") || (u != u2 && ci->IsPeace() && u2_access >= u_access); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << mask; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), mask); if (!c->HasMode(mode, mask)) { @@ -188,7 +188,7 @@ class CommandCSBan : public Command Anope::string mask = IRCD->NormalizeMask(target); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << mask; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), mask); if (!c->HasMode(mode, mask)) { diff --git a/modules/chanserv/clone.cpp b/modules/chanserv/clone.cpp index 8d0c1ce3a..343e6c5b2 100644 --- a/modules/chanserv/clone.cpp +++ b/modules/chanserv/clone.cpp @@ -209,7 +209,8 @@ public: return; } - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->GetName(); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clone {0} to {1}"), + what.empty() ? "everything from it" : what, target_ci->GetName()); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/chanserv/drop.cpp b/modules/chanserv/drop.cpp index 77ab7e55e..122ac96b8 100644 --- a/modules/chanserv/drop.cpp +++ b/modules/chanserv/drop.cpp @@ -63,7 +63,8 @@ class CommandCSDrop : public Command return; bool override = (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "none") << ")"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} (founder was: {0})"), + ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "none"); Reference c = ci->c; ci->Delete(); diff --git a/modules/chanserv/enforce.cpp b/modules/chanserv/enforce.cpp index e1d084075..8d41c7af3 100644 --- a/modules/chanserv/enforce.cpp +++ b/modules/chanserv/enforce.cpp @@ -25,7 +25,7 @@ class CommandCSEnforce : public Command void DoSecureOps(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce secureops"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce secureops")); /* Dirty hack to allow Channel::SetCorrectModes to work ok. * We pretend like SECUREOPS is on so it doesn't ignore that @@ -51,7 +51,7 @@ class CommandCSEnforce : public Command void DoRestricted(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce restricted"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce restricted")); std::vector users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -82,7 +82,7 @@ class CommandCSEnforce : public Command void DoRegOnly(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce registered only"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce registered only")); std::vector users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -114,7 +114,7 @@ class CommandCSEnforce : public Command void DoSSLOnly(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce SSL only"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce SSL only")); std::vector users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -146,7 +146,7 @@ class CommandCSEnforce : public Command void DoBans(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce bans"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce bans")); std::vector users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -175,7 +175,7 @@ class CommandCSEnforce : public Command void DoLimit(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enforce limit"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce limit")); Anope::string l_str; if (!ci->c->GetParam("LIMIT", l_str)) diff --git a/modules/chanserv/entrymsg.cpp b/modules/chanserv/entrymsg.cpp index c739ba46a..b2edbc56f 100644 --- a/modules/chanserv/entrymsg.cpp +++ b/modules/chanserv/entrymsg.cpp @@ -151,7 +151,9 @@ class CommandEntryMessage : public Command msg->SetChannel(ci); msg->SetCreator(source.GetNick()); msg->SetMessage(message); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to add a message"; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to add a message")); + source.Reply(_("Entry message added to \002{0}\002"), ci->GetName()); } @@ -177,7 +179,9 @@ class CommandEntryMessage : public Command if (i > 0 && i <= messages.size()) { messages[i - 1]->Delete(); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove a message"; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to remove a message")); + source.Reply(_("Entry message \002{0}\002 for \002{1]\002 deleted."), i, ci->GetName()); } else @@ -192,9 +196,10 @@ class CommandEntryMessage : public Command void DoClear(CommandSource &source, ChanServ::Channel *ci) { for (EntryMsg *e : ci->GetRefs()) - delete e; + e->Delete(); + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to remove all messages")); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove all messages"; source.Reply(_("Entry messages for \002{0}\002 have been cleared."), ci->GetName()); } diff --git a/modules/chanserv/flags.cpp b/modules/chanserv/flags.cpp index 4732aff5b..d87863be0 100644 --- a/modules/chanserv/flags.cpp +++ b/modules/chanserv/flags.cpp @@ -266,9 +266,12 @@ class CommandCSFlags : public Command if (current != NULL) { EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, current); - delete current; - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; - source.Reply(_("\002{0}\002 removed from the access list of \002{1}\002."), mask, ci->GetName()); + + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), current->Mask()); + + source.Reply(_("\002{0}\002 removed from the access list of \002{1}\002."), current->Mask(), ci->GetName()); + + current->Delete(); } else { @@ -290,11 +293,12 @@ class CommandCSFlags : public Command access->SetFlags(Anope::string(current_flags.begin(), current_flags.end())); if (current != NULL) - delete current; + current->Delete(); EventManager::Get()->Dispatch(&Event::AccessAdd::OnAccessAdd, ci, source, access); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->AccessSerialize(); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to modify flags of {0} to {1}"), access->Mask(), access->AccessSerialize()); + if (p != NULL) { if (add) @@ -303,7 +307,9 @@ class CommandCSFlags : public Command source.Reply(_("Privilege \002{0}\002 removed from \002{1}\002 on \002{2}\002, new flags are +\002{3}\002"), p->name, access->Mask(), ci->GetName(), access->AccessSerialize()); } else + { source.Reply(_("Flags for \002{0}\002 on \002{1}\002 set to +\002{2}\002"), access->Mask(), ci->GetName(), access->AccessSerialize()); + } } void DoList(CommandSource &source, ChanServ::Channel *ci, const std::vector ¶ms) @@ -383,7 +389,7 @@ class CommandCSFlags : public Command source.Reply(_("The access list of \002{0}\002 has been cleared."), ci->GetName()); bool override = !source.IsFounder(ci); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list"; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the access list")); } public: diff --git a/modules/chanserv/getkey.cpp b/modules/chanserv/getkey.cpp index cbcc66720..2e6835672 100644 --- a/modules/chanserv/getkey.cpp +++ b/modules/chanserv/getkey.cpp @@ -53,7 +53,7 @@ class CommandCSGetKey : public Command } bool override = !source.AccessFor(ci).HasPriv("GETKEY"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); source.Reply(_("Key for channel \002{0}\002 is \002{1}\002."), ci->GetName(), key); } diff --git a/modules/chanserv/invite.cpp b/modules/chanserv/invite.cpp index 9c21bc704..ae6cee04d 100644 --- a/modules/chanserv/invite.cpp +++ b/modules/chanserv/invite.cpp @@ -83,12 +83,12 @@ class CommandCSInvite : public Command { source.Reply(_("\002{0}\002 has been invited to \002{1}\002."), u2->nick, c->name); u2->SendMessage(ci->WhoSends(), _("You have been invited to \002{0}\002 by \002{1}\002."), c->name, source.GetNick()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << u2->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to invite {0}"), u2->nick); } else { u2->SendMessage(ci->WhoSends(), _("You have been invited to \002{0}\002."), c->name); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); } } diff --git a/modules/chanserv/kick.cpp b/modules/chanserv/kick.cpp index 505f74893..fad7b9158 100644 --- a/modules/chanserv/kick.cpp +++ b/modules/chanserv/kick.cpp @@ -79,7 +79,7 @@ class CommandCSKick : public Command else { bool override = !u_access.HasPriv("KICK") || (u != u2 && ci->IsPeace() && u2_access >= u_access); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << u2->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), u2->nick); if (ci->IsSignKick() || (ci->IsSignKickLevel() && !u_access.HasPriv("SIGNKICK"))) { @@ -96,7 +96,7 @@ class CommandCSKick : public Command { Anope::string mask = IRCD->NormalizeMask(target); - Log(LOG_COMMAND, source, this, ci) << "for " << mask; + logger.Command(LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), mask); int matched = 0, kicked = 0; for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end;) diff --git a/modules/chanserv/list.cpp b/modules/chanserv/list.cpp index a60ae786c..cd855a0b3 100644 --- a/modules/chanserv/list.cpp +++ b/modules/chanserv/list.cpp @@ -215,13 +215,15 @@ class CommandCSSetPrivate : public Command if (params[1].equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable private"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable private")); + ci->SetPrivate(true); source.Reply(_("Private option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (params[1].equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable private"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable private")); + ci->SetPrivate(false); source.Reply(_("Private option for \002{0}\002 is now \002off\002."), ci->GetName()); } diff --git a/modules/chanserv/log.cpp b/modules/chanserv/log.cpp index 4cbc66c7e..52724a57b 100644 --- a/modules/chanserv/log.cpp +++ b/modules/chanserv/log.cpp @@ -285,15 +285,24 @@ public: { if (log->GetExtra() == extra) { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to remove logging for " << command << " with method " << method << (extra == "" ? "" : " ") << extra; - source.Reply(_("Logging for command \002{0}\002 on \002{1}\002 with log method \002{2}{3}{4}\002 has been removed."), !log->GetCommandName().empty() ? log->GetCommandName() : log->GetServiceName(), !log->GetCommandService().empty() ? log->GetCommandService() : "any service", method, extra.empty() ? "" : " ", extra); - delete log; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to remove logging for {0} with method {1}"), + command, method + (extra.empty() ? "" : (" " + extra))); + + source.Reply(_("Logging for command \002{0}\002 on \002{1}\002 with log method \002{2}{3}{4}\002 has been removed."), + !log->GetCommandName().empty() ? log->GetCommandName() : log->GetServiceName(), + !log->GetCommandService().empty() ? log->GetCommandService() : "any service", method, extra.empty() ? "" : " ", extra); + log->Delete(); } else { log->SetExtra(extra); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to change logging for " << command << " to method " << method << (extra == "" ? "" : " ") << extra; - source.Reply(_("Logging changed for command \002{0}\002 on \002{1}\002, now using log method \002{2}{3}{4]\002."), !log->GetCommandName().empty() ? log->GetCommandName() : log->GetServiceName(), !log->GetCommandService().empty() ? log->GetCommandService() : "any service", method, extra.empty() ? "" : " ", extra); + + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to change logging for {0} to method {1}"), + command, method + (extra.empty() ? "" : (" " + extra))); + + source.Reply(_("Logging changed for command \002{0}\002 on \002{1}\002, now using log method \002{2}{3}{4]\002."), + !log->GetCommandName().empty() ? log->GetCommandName() : log->GetServiceName(), + !log->GetCommandService().empty() ? log->GetCommandService() : "any service", method, extra.empty() ? "" : " ", extra); } return; } @@ -310,9 +319,11 @@ public: log->SetCreated(Anope::CurTime); log->SetCreator(source.GetNick()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to log " << command << " with method " << method << (extra == "" ? "" : " ") << extra; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, + _("{source} used {command} on {channel} to log {0} to method {1}"), command, method + (extra.empty() ? "" : (" " + extra))); - source.Reply(_("Logging is now active for command \002{0}\002 on \002{1}\002, using log method \002{2}{3}{4}\002."), !command_name.empty() ? command_name : service_name, bi ? bi->nick : "any service", method, extra.empty() ? "" : " ", extra); + source.Reply(_("Logging is now active for command \002{0}\002 on \002{1}\002, using log method \002{2}{3}{4}\002."), + !command_name.empty() ? command_name : service_name, bi ? bi->nick : "any service", method, extra.empty() ? "" : " ", extra); } else { @@ -423,9 +434,11 @@ class CSLog : public Module } } - void OnLog(::Log *l) override + void OnLog(Logger *l) override { - if (l->type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced()) +#warning "fix log" +#if 0 + if (l->type != LogType::COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced()) return; std::vector ls = l->ci->GetRefs(); @@ -463,6 +476,7 @@ class CSLog : public Module else if (log->GetMethod().equals_ci("NOTICE") && l->ci->c) IRCD->SendNotice(l->ci->WhoSends(), log->GetExtra() + l->ci->c->name, buffer); } +#endif } }; diff --git a/modules/chanserv/main/channel.cpp b/modules/chanserv/main/channel.cpp index a35c80901..d10abbc0d 100644 --- a/modules/chanserv/main/channel.cpp +++ b/modules/chanserv/main/channel.cpp @@ -30,7 +30,7 @@ void ChannelImpl::Delete() { EventManager::Get()->Dispatch(&Event::DelChan::OnDelChan, this); - Log(LOG_DEBUG) << "Deleting channel " << this->GetName(); + Anope::Logger.Debug("Deleting channel {0}", this->GetName()); if (this->c) { @@ -361,7 +361,7 @@ ChanServ::AccessGroup ChannelImpl::AccessFor(const User *u, bool updateLastUsed) return group; NickServ::Account *nc = u->Account(); - if (nc == NULL && !nc->IsSecure() && u->IsRecognized()) + if (nc == NULL && !this->IsSecure() && u->IsRecognized()) { NickServ::Nick *na = NickServ::FindNick(u->nick); if (na != NULL) @@ -480,7 +480,7 @@ int16_t ChannelImpl::GetLevel(const Anope::string &priv) ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(priv) : nullptr; if (!p) { - Log(LOG_DEBUG) << "Unknown privilege " + priv; + Anope::Logger.Debug("Unknown privilege {0}", priv); return ChanServ::ACCESS_INVALID; } @@ -499,7 +499,7 @@ void ChannelImpl::SetLevel(const Anope::string &priv, int16_t level) ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(priv) : nullptr; if (!p) { - Log(LOG_DEBUG) << "Unknown privilege " + priv; + Anope::Logger.Debug("Unknown privilege {0}", priv); return; } @@ -538,7 +538,7 @@ Anope::string ChannelImpl::GetIdealBan(User *u) else return "*!" + u->GetVIdent() + "@" + u->GetDisplayedHost(); case 3: - return "*!" + u->Mask(); + return "*!" + u->WildMask(); case 2: default: return "*!*@" + u->GetDisplayedHost(); diff --git a/modules/chanserv/main/chanserv.cpp b/modules/chanserv/main/chanserv.cpp index 492f64459..62d1e81ba 100644 --- a/modules/chanserv/main/chanserv.cpp +++ b/modules/chanserv/main/chanserv.cpp @@ -309,7 +309,9 @@ class ChanServCore : public Module if (newowner) { - ::Log(LOG_NORMAL, "chanserv/drop", ChanServ) << "Transferring foundership of " << ci->GetName() << " from deleted account " << nc->GetDisplay() << " to " << newowner->GetDisplay(); + ChanServ->logger.Category("chanserv/drop").Log(_("Transferring foundership of {0} from deleted account {1} to {2}"), + ci->GetName(), nc->GetDisplay(), newowner->GetDisplay()); + ci->SetFounder(newowner); // Can't be both founder and successor @@ -318,7 +320,8 @@ class ChanServCore : public Module } else { - ::Log(LOG_NORMAL, "chanserv/drop", ChanServ) << "Deleting channel " << ci->GetName() << " owned by deleted account " << nc->GetDisplay(); + ChanServ->logger.Category("chanserv/drop").Log(_("Deleting channel {0} owned by deleted account {1}"), + ci->GetName(), nc->GetDisplay()); ci->Delete(); continue; @@ -408,10 +411,13 @@ class ChanServCore : public Module } } - void OnLog(::Log *l) override + void OnLog(Logger *l) override { - if (l->type == LOG_CHANNEL) +#warning "" +#if 0 + if (l->type == LogType::CHANNEL) l->bi = ChanServ; +#endif } void OnExpireTick() override @@ -442,7 +448,9 @@ class ChanServCore : public Module if (expire) { - ::Log(LOG_NORMAL, "chanserv/expire", ChanServ) << "Expiring channel " << ci->GetName() << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "(none)") << ")"; + ChanServ->logger.Category("chanserv/expire").Log(_("Expiring channel {0} (founder: {1})"), + ci->GetName(), ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "(none)"); + EventManager::Get()->Dispatch(&ChanServ::Event::ChanExpire::OnChanExpire, ci); ci->Delete(); } @@ -511,7 +519,7 @@ class ChanServCore : public Module { if (always_lower && c->ci && c->creation_time > c->ci->GetTimeRegistered()) { - ::Log(LOG_DEBUG) << "Changing TS of " << c->name << " from " << c->creation_time << " to " << c->ci->GetTimeRegistered(); + logger.Debug("Changing TS of {0} from {1} to {2}", c->name, c->creation_time, c->ci->GetTimeRegistered()); c->creation_time = c->ci->GetTimeRegistered(); IRCD->Send(c); c->Reset(); diff --git a/modules/chanserv/mode.cpp b/modules/chanserv/mode.cpp index 5a22b4be8..e76469823 100644 --- a/modules/chanserv/mode.cpp +++ b/modules/chanserv/mode.cpp @@ -374,7 +374,8 @@ class CommandCSMode : public Command if (!reply.empty()) { source.Reply(_("\002{0}\002 locked on \002{1}\002."), reply, ci->GetName()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to lock " << reply; + + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to lock {0}"), reply); } else if (needreply) { @@ -430,7 +431,9 @@ class CommandCSMode : public Command if (!mode_param.empty()) mode_param = " " + mode_param; source.Reply(_("\002{0}{1}{2}\002 has been unlocked from \002{3}\002."), adding == 1 ? '+' : '-', cm->mchar, mode_param, ci->GetName()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->mchar << mode_param; + + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to unlock {0}"), + (adding ? '+' : '-') + cm->mchar + mode_param); } else { @@ -493,7 +496,8 @@ class CommandCSMode : public Command Anope::string modes = params[2], param; bool override = !source.AccessFor(ci).HasPriv("MODE") && source.HasPriv("chanserv/administration"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << params[2] << (params.size() > 3 ? " " + params[3] : ""); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to set {3}"), + params[2] + (params.size() > 3 ? " " + params[3] : "")); int adding = -1; for (size_t i = 0; i < modes.length(); ++i) @@ -850,7 +854,7 @@ class CommandCSModes : public Command else ci->c->RemoveMode(NULL, m.second, targ->GetUID()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "on " << targ->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} on {3}"), targ->nick); } const Anope::string GetDesc(CommandSource &source) const override diff --git a/modules/chanserv/register.cpp b/modules/chanserv/register.cpp index 1e2a6a2bd..0e7bff7a0 100644 --- a/modules/chanserv/register.cpp +++ b/modules/chanserv/register.cpp @@ -121,7 +121,8 @@ class CommandCSRegister : public Command ci->SetLastTopicSetter(source.service->nick); } - Log(LOG_COMMAND, source, this, ci); + logger.Command(LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); + source.Reply(_("Channel \002{0}\002 registered under your account: \002{1}\002"), chan, nc->GetDisplay()); /* Implement new mode lock */ diff --git a/modules/chanserv/seen.cpp b/modules/chanserv/seen.cpp index 113691343..2028634f4 100644 --- a/modules/chanserv/seen.cpp +++ b/modules/chanserv/seen.cpp @@ -165,12 +165,12 @@ class CommandOSSeen : public Command ++it; if (time < buf->second->last) { - Log(LOG_DEBUG) << buf->first << " was last seen " << Anope::strftime(buf->second->last) << ", deleting entry"; + Log(LogType::DEBUG) << buf->first << " was last seen " << Anope::strftime(buf->second->last) << ", deleting entry"; delete buf->second; counter++; } } - Log(LOG_ADMIN, source, this) << "CLEAR and removed " << counter << " nicks that were added after " << Anope::strftime(time, NULL, true); + Log(LogType::ADMIN, source, this) << "CLEAR and removed " << counter << " nicks that were added after " << Anope::strftime(time, NULL, true); source.Reply(_("Database cleared, removed %lu nicks that were added after %s."), counter, Anope::strftime(time, source.nc, true).c_str()); } else @@ -423,11 +423,11 @@ class CSSeen : public Module if ((Anope::CurTime - cur->second->last) > purgetime) { - Log(LOG_DEBUG) << cur->first << " was last seen " << Anope::strftime(cur->second->last) << ", purging entries"; + Log(LogType::DEBUG) << cur->first << " was last seen " << Anope::strftime(cur->second->last) << ", purging entries"; delete cur->second; } } - Log(LOG_DEBUG) << "cs_seen: Purged database, checked " << previous_size << " nicks and removed " << (previous_size - database.size()) << " old entries."; + Log(LogType::DEBUG) << "cs_seen: Purged database, checked " << previous_size << " nicks and removed " << (previous_size - database.size()) << " old entries."; } void OnUserConnect(User *u, bool &exempt) override diff --git a/modules/chanserv/set.cpp b/modules/chanserv/set.cpp index 833817cde..7b6775c2f 100644 --- a/modules/chanserv/set.cpp +++ b/modules/chanserv/set.cpp @@ -26,7 +26,7 @@ class CommandCSSet : public Command { ServiceReference mlocks; - + public: CommandCSSet(Module *creator) : Command(creator, "chanserv/set", 2, 3) { @@ -117,13 +117,15 @@ class CommandCSSetAutoOp : public Command if (params[1].equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable autoop"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable autoop")); + ci->SetNoAutoop(false); source.Reply(_("Services will now automatically give modes to users in \002{0}\002."), ci->GetName()); } else if (params[1].equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable autoop"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable autoop")); + ci->SetNoAutoop(true); source.Reply(_("Services will no longer automatically give modes to users in \002{0}\002."), ci->GetName()); } @@ -182,7 +184,9 @@ class CommandCSSetBanType : public Command int16_t new_type = convertTo(params[1]); if (new_type < 0 || new_type > 3) throw ConvertException("Invalid range"); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change the ban type to " << new_type; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the ban type to {0}"), new_type); + ci->SetBanType(new_type); source.Reply(_("Ban type for channel \002{0}\002 is now \002#{1}\002."), ci->GetName(), new_type); } @@ -247,12 +251,14 @@ class CommandCSSetDescription : public Command ci->SetDesc(param); if (!param.empty()) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change the description to " << ci->GetDesc(); + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the description to {0}"), ci->GetDesc()); + source.Reply(_("Description of \002{0}\002 changed to \002{1}\002."), ci->GetName(), ci->GetDesc()); } else { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to unset the description"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to unset the description")); + source.Reply(_("Description of \002{0}\002 unset."), ci->GetName()); } } @@ -317,7 +323,8 @@ class CommandCSSetFounder : public Command return; } - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change the founder from " << (ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "(none)") << " to " << nc->GetDisplay(); + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the founder from {0} to {1}"), + ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "(none)", nc->GetDisplay()); ci->SetFounder(nc); @@ -373,7 +380,8 @@ class CommandCSSetKeepModes : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable keep modes"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable keep modes")); + ci->SetKeepModes(true); source.Reply(_("Keep modes for \002{0}\002 is now \002on\002."), ci->GetName()); if (ci->c) @@ -387,7 +395,8 @@ class CommandCSSetKeepModes : public Command } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable keep modes"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable keep modes")); + ci->SetKeepModes(false); source.Reply(_("Keep modes for \002{0}\002 is now \002off\002."), ci->GetName()); for (ChanServ::Mode *m : ci->GetRefs()) @@ -446,13 +455,15 @@ class CommandCSSetPeace : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable peace"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable peace")); + ci->SetPeace(true); source.Reply(_("Peace option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable peace"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable peace")); + ci->SetPeace(false); source.Reply(_("Peace option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -481,7 +492,7 @@ inline static Anope::string BotModes() class CommandCSSetPersist : public Command { ServiceReference mlocks; - + public: CommandCSSetPersist(Module *creator, const Anope::string &cname = "chanserv/set/persist") : Command(creator, cname, 2, 2) { @@ -570,7 +581,8 @@ class CommandCSSetPersist : public Command } } - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable persist"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable persist")); + source.Reply(_("Channel \002{0}\002 is now persistent."), ci->GetName()); } else if (params[1].equals_ci("OFF")) @@ -607,7 +619,8 @@ class CommandCSSetPersist : public Command } } - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable persist"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable persist")); + source.Reply(_("Channel \002{0}\002 is no longer persistent."), ci->GetName()); } else @@ -664,13 +677,15 @@ class CommandCSSetRestricted : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable restricted"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable restricted")); + ci->SetRestricted(true); source.Reply(_("Restricted access option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable restricted"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disabled restricted")); + ci->SetRestricted(false); source.Reply(_("Restricted access option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -727,13 +742,15 @@ class CommandCSSetSecure : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable secure"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable secure")); + ci->SetSecure(true); source.Reply(_("Secure option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable secure"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable secure")); + ci->SetSecure(false); source.Reply(_("Secure option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -792,13 +809,15 @@ class CommandCSSetSecureFounder : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable secure founder"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable secure founder")); + ci->SetSecureFounder(true); source.Reply(_("Secure founder option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable secure founder"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable secure founder")); + ci->SetSecureFounder(false); source.Reply(_("Secure founder option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -860,13 +879,15 @@ class CommandCSSetSecureOps : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable secure ops"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable secure ops")); + ci->SetSecureOps(true); source.Reply(_("Secure ops option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable secure ops"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable secure ops")); + ci->SetSecureOps(false); source.Reply(_("Secure ops option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -927,21 +948,24 @@ class CommandCSSetSignKick : public Command ci->SetSignKick(true); ci->SetSignKickLevel(false); source.Reply(_("Signed kick option for \002{0}\002 is now \002on\002."), ci->GetName()); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable sign kick"; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable sign kick")); } else if (param.equals_ci("LEVEL")) { ci->SetSignKick(false); ci->SetSignKickLevel(true); source.Reply(_("Signed kick option for \002{0}\002 is now \002on\002, but depends of the privileges of the user that is using the command."), ci->GetName()); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable sign kick level"; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable sign kick level")); } else if (param.equals_ci("OFF")) { ci->SetSignKick(false); ci->SetSignKickLevel(false); source.Reply(_("Signed kick option for \002{0}\002 is now \002off\002."), ci->GetName()); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable sign kick"; + + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable sign kick")); } else { @@ -1018,7 +1042,8 @@ class CommandCSSetSuccessor : public Command nc = na->GetAccount(); } - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change the successor from " << (ci->GetSuccessor() ? ci->GetSuccessor()->GetDisplay() : "(none)") << " to " << (nc ? nc->GetDisplay() : "(none)"); + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the successor from {0} to {1}"), + ci->GetSuccessor() ? ci->GetSuccessor()->GetDisplay() : "(none)", nc ? nc->GetDisplay() : "(none)"); ci->SetSuccessor(nc); @@ -1072,13 +1097,15 @@ class CommandCSSetNoexpire : public Command if (param.equals_ci("ON")) { - Log(LOG_ADMIN, source, this, ci) << "to enable noexpire"; + logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} to enable noexpire")); + ci->SetNoExpire(true); source.Reply(_("Channel \002{0} will not\002 expire."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(LOG_ADMIN, source, this, ci) << "to disable noexpire"; + logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} to disable noexpire")); + ci->SetNoExpire(false); source.Reply(_("Channel \002{0} will\002 expire."), ci->GetName()); } @@ -1240,7 +1267,7 @@ class CSSet : public Module { if (persist_lower_ts && c->ci && c->ci->IsPersist() && c->creation_time > c->ci->GetTimeRegistered()) { - Log(LOG_DEBUG) << "Changing TS of " << c->name << " from " << c->creation_time << " to " << c->ci->GetTimeRegistered(); + logger.Debug("Changing TS of {0} from {1} to {2}", c->name, c->creation_time, c->ci->GetTimeRegistered()); c->creation_time = c->ci->GetTimeRegistered(); IRCD->Send(c); c->Reset(); diff --git a/modules/chanserv/set_misc.cpp b/modules/chanserv/set_misc.cpp index 7bf55dfc6..76f4c7017 100644 --- a/modules/chanserv/set_misc.cpp +++ b/modules/chanserv/set_misc.cpp @@ -151,12 +151,16 @@ class CommandCSSetMisc : public Command data->SetName(scommand); data->SetData(param); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change it to " << param; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, + _("{source} used {command} on {channel} to change it to {0}"), + param); + source.Reply(_("\002{0}\002 for \002{1}\002 set to \002{2}\002."), scommand, ci->GetName(), param); } else { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to unset it"; + logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to unset it")); + source.Reply(_("\002{0}\002 for \002{1}\002 unset."), scommand, ci->GetName()); } } diff --git a/modules/chanserv/suspend.cpp b/modules/chanserv/suspend.cpp index 7895aaa02..c686ffdb7 100644 --- a/modules/chanserv/suspend.cpp +++ b/modules/chanserv/suspend.cpp @@ -189,7 +189,9 @@ class CommandCSSuspend : public Command ci->c->Kick(NULL, users[i], !reason.empty() ? reason : Language::Translate(users[i], _("This channel has been suspended."))); } - Log(LOG_ADMIN, source, this, ci) << "(" << (!reason.empty() ? reason : "No reason") << "), expires on " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); + logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} ({0}), expires on {1}"), + !reason.empty() ? reason : "No reason", expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); + source.Reply(_("Channel \002{0}\002 is now suspended."), ci->GetName()); EventManager::Get()->Dispatch(&Event::ChanSuspend::OnChanSuspend, ci); @@ -234,11 +236,12 @@ class CommandCSUnSuspend : public Command return; } - Log(LOG_ADMIN, source, this, ci) << "which was suspended by " << si->GetBy() << " for: " << (!si->GetReason().empty() ? si->GetReason() : "No reason"); + logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} which was suspended by {0} for: {1}"), + si->GetBy(), !si->GetReason().empty() ? si->GetReason() : "No reason"); si->Delete(); - source.Reply(_("Channel \002%s\002 is now released."), ci->GetName().c_str()); + source.Reply(_("Channel \002{0}\002 is now released."), ci->GetName()); EventManager::Get()->Dispatch(&Event::ChanUnsuspend::OnChanUnsuspend, ci); } @@ -320,7 +323,7 @@ class CSSuspend : public Module ci->SetLastUsed(Anope::CurTime); si->Delete(); - Log(this) << "Expiring suspend for " << ci->GetName(); + logger.Channel(ci).Log(_("Expiring suspend for {0}"), ci->GetName()); } } diff --git a/modules/chanserv/sync.cpp b/modules/chanserv/sync.cpp index 9f9ba4ff7..c532d4fad 100644 --- a/modules/chanserv/sync.cpp +++ b/modules/chanserv/sync.cpp @@ -52,7 +52,7 @@ class CommandCSSync : public Command } bool override = !source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/administration"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) ci->c->SetCorrectModes(it->second->user, true); diff --git a/modules/chanserv/topic.cpp b/modules/chanserv/topic.cpp index db4d25dbd..648c322fb 100644 --- a/modules/chanserv/topic.cpp +++ b/modules/chanserv/topic.cpp @@ -62,13 +62,15 @@ class CommandCSSetKeepTopic : public Command if (param.equals_ci("ON")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable keeptopic"; + logger.Command(!source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to enable keeptopic")); + ci->SetKeepTopic(true); source.Reply(_("Topic retention option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable keeptopic"; + logger.Command(!source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to disable keeptopic")); + ci->SetKeepTopic(false); source.Reply(_("Topic retention option for \002{0}\002 is now \002off\002."), ci->GetName()); } @@ -132,7 +134,10 @@ class CommandCSTopic : public Command ci->SetTopicLock(true); bool override = !source.AccessFor(ci).HasPriv("TOPIC"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << (!topic.empty() ? "to change the topic to: " : "to unset the topic") << (!topic.empty() ? topic : ""); + if (!topic.empty()) + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to change the topic to: {0}"), topic); + else + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to unset the topic")); } void Append(CommandSource &source, ChanServ::Channel *ci, const std::vector ¶ms) diff --git a/modules/chanserv/unban.cpp b/modules/chanserv/unban.cpp index 035819ff2..ac7c08fdf 100644 --- a/modules/chanserv/unban.cpp +++ b/modules/chanserv/unban.cpp @@ -42,20 +42,20 @@ class CommandCSUnban : public Command if (!source.GetUser()) return; - unsigned count = 0; + unsigned int count = 0; for (ChanServ::Channel *ci : source.GetAccount()->GetRefs()) { if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN")) continue; - for (unsigned j = 0; j < modes.size(); ++j) + for (unsigned int j = 0; j < modes.size(); ++j) if (ci->c->Unban(source.GetUser(), modes[j]->name, true)) ++count; } - Log(LOG_COMMAND, source, this, NULL) << "on all channels"; - source.Reply(_("You have been unbanned from %d channels."), count); + logger.Command(LogType::COMMAND, source, _("{source} used {command} on all channels")); + source.Reply(_("You have been unbanned from \002{0}\002 channels."), count); return; } @@ -92,7 +92,7 @@ class CommandCSUnban : public Command } bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unban " << u2->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to unban {0}"), u2->nick); for (unsigned i = 0; i < modes.size(); ++i) ci->c->Unban(u2, modes[i]->name, source.GetUser() == u2); diff --git a/modules/chanserv/updown.cpp b/modules/chanserv/updown.cpp index 38ed65776..d3ceb617a 100644 --- a/modules/chanserv/updown.cpp +++ b/modules/chanserv/updown.cpp @@ -68,7 +68,8 @@ class CommandCSUp : public Command Channel *c = it->second->chan; SetModes(source.GetUser(), c); } - Log(LOG_COMMAND, source, this, NULL) << "on all channels to update their status modes"; + + logger.Command(LogType::COMMAND, source, _("{source} used {command} on all channels to update their status modes"), source.GetSource(), source.GetCommand()); return; } @@ -131,7 +132,8 @@ class CommandCSUp : public Command } } - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to update the status modes of " << u->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to update the status modes of {0}"), u->nick); + SetModes(u, c); } @@ -172,7 +174,7 @@ class CommandCSDown : public Command Channel *c = it->second->chan; RemoveAll(source.GetUser(), c); } - Log(LOG_COMMAND, source, this, NULL) << "on all channels to remove their status modes"; + logger.Command(LogType::COMMAND, source, _("{source} used {command} on all channels to remove their status modes"), source.GetSource(), source.GetCommand()); return; } @@ -236,7 +238,8 @@ class CommandCSDown : public Command } } - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to remove the status modes from " << u->nick; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to remove the status modes from {0}"), u->nick); + RemoveAll(u, c); } diff --git a/modules/chanserv/xop.cpp b/modules/chanserv/xop.cpp index de5ca0c0b..b95580a2b 100644 --- a/modules/chanserv/xop.cpp +++ b/modules/chanserv/xop.cpp @@ -134,7 +134,7 @@ class CommandCSXOP : public Command if (Anope::ReadOnly) { - source.Reply(_("Sorry, channel %s list modification is temporarily disabled."), source.command.c_str()); + source.Reply(_("Sorry, channel {0} list modification is temporarily disabled."), source.command); return; } @@ -244,10 +244,10 @@ class CommandCSXOP : public Command acc->SetLastSeen(0); acc->SetCreated(Anope::CurTime); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0}"), mask); EventManager::Get()->Dispatch(&Event::AccessAdd::OnAccessAdd, ci, source, acc); - source.Reply(_("\002%s\002 added to %s %s list."), acc->Mask(), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("\002{0}\002 added to {1} {2} list."), acc->Mask(), ci->GetName(), source.command); } void DoDel(CommandSource &source, ChanServ::Channel *ci, const std::vector ¶ms) @@ -263,13 +263,13 @@ class CommandCSXOP : public Command if (Anope::ReadOnly) { - source.Reply(_("Sorry, channel %s list modification is temporarily disabled."), source.command.c_str()); + source.Reply(_("Sorry, channel {0} list modification is temporarily disabled."), source.command); return; } if (!ci->GetAccessCount()) { - source.Reply(_("%s %s list is empty."), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("{0} {1} list is empty."), ci->GetName(), source.command); return; } @@ -327,20 +327,20 @@ class CommandCSXOP : public Command nicks = caccess->Mask(); EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, caccess); - delete caccess; + caccess->Delete(); }, [&]() { if (!deleted) - source.Reply(_("No matching entries on %s %s list."), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("No matching entries on {0} {1} list."), ci->GetName(), source.command); else { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << nicks; + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), nicks); if (deleted == 1) - source.Reply(_("Deleted one entry from %s %s list."), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("Deleted one entry from {0} {1} list."), ci->GetName(), source.command); else - source.Reply(_("Deleted %d entries from %s %s list."), deleted, ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("Deleted {0} entries from {1} {2} list."), deleted, ci->GetName(), source.command); } }); } @@ -355,18 +355,18 @@ class CommandCSXOP : public Command if (a->Mask().equals_ci(mask)) { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << a->Mask(); + logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), a->GetMask()); - source.Reply(_("\002%s\002 deleted from %s %s list."), a->Mask().c_str(), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("\002{0}\002 deleted from {1} {2} list."), a->Mask(), ci->GetName(), source.command); EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, a); - delete a; + a->Delete(); return; } } - source.Reply(_("\002%s\002 not found on %s %s list."), mask.c_str(), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("\002{0}\002 not found on {1} {2} list."), mask, ci->GetName(), source.command); } } @@ -385,7 +385,7 @@ class CommandCSXOP : public Command if (!ci->GetAccessCount()) { - source.Reply(_("%s %s list is empty."), ci->GetName().c_str(), source.command.c_str()); + source.Reply(_("{0} {1} list is empty."), ci->GetName(), source.command); return; } @@ -432,14 +432,14 @@ class CommandCSXOP : public Command if (list.Is