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/operserv/akill.cpp | 20 ++++++++++------- modules/operserv/chankill.cpp | 2 +- modules/operserv/config.cpp | 5 +++-- modules/operserv/defcon.cpp | 26 +++++++++++----------- modules/operserv/dns.cpp | 44 ++++++++++++++++++++++---------------- modules/operserv/forbid.cpp | 8 ++++--- modules/operserv/ignore.cpp | 16 ++++++++------ modules/operserv/info.cpp | 9 +++++--- modules/operserv/jupe.cpp | 4 ++-- modules/operserv/kick.cpp | 2 +- modules/operserv/kill.cpp | 4 +++- modules/operserv/list.cpp | 8 +++---- modules/operserv/login.cpp | 6 ++++-- modules/operserv/logsearch.cpp | 6 ++++-- modules/operserv/main/operserv.cpp | 27 +++++++++++++---------- modules/operserv/mode.cpp | 17 ++++++++------- modules/operserv/modinfo.cpp | 7 +++--- modules/operserv/module.cpp | 8 +++---- modules/operserv/news.cpp | 14 ++++++++---- modules/operserv/noop.cpp | 7 ++++-- modules/operserv/oper.cpp | 6 ++++-- modules/operserv/reload.cpp | 4 ++-- modules/operserv/session.cpp | 14 ++++++------ modules/operserv/set.cpp | 23 +++++++++++--------- modules/operserv/shutdown.cpp | 4 ++-- modules/operserv/stats.cpp | 4 ++-- modules/operserv/svs.cpp | 17 +++++++++++---- modules/operserv/sxline.cpp | 39 ++++++++++++++++++++++----------- 28 files changed, 212 insertions(+), 139 deletions(-) (limited to 'modules/operserv') diff --git a/modules/operserv/akill.cpp b/modules/operserv/akill.cpp index 9c4a53d23..10a87db2b 100644 --- a/modules/operserv/akill.cpp +++ b/modules/operserv/akill.cpp @@ -147,11 +147,12 @@ class CommandOSAKill : public Command ++affected; float percent = static_cast(affected) / static_cast(UserListByNick.size()) * 100.0; - if (percent > 95) + if (percent > 95) // XXX make this configurable.. { source.Reply(_("\002{0}\002 coverage is too wide; Please use a more specific mask."), mask); - Log(LOG_ADMIN, source, this) << "tried to akill " << percent << "% of the network (" << affected << " users)"; - delete x; + logger.Command(LogType::ADMIN, source, _("{source} used {command} and tried to akill {0}% of the network ({1} users)"), + 95, affected); + x->Delete(); return; } @@ -159,7 +160,7 @@ class CommandOSAKill : public Command MOD_RESULT = EventManager::Get()->Dispatch(&Event::AddXLine::OnAddXLine, source, x, akills); if (MOD_RESULT == EVENT_STOP) { - delete x; + x->Delete(); return; } @@ -169,7 +170,8 @@ class CommandOSAKill : public Command source.Reply(_("\002{0}\002 added to the akill list."), mask); - Log(LOG_ADMIN, source, this) << "on " << mask << " (" << x->GetReason() << "), expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} ({1}), expires in {2} [affects {3} user(s) ({4}%)]"), + mask, x->GetReason(), expires ? Anope::Duration(expires - Anope::CurTime) : "never", affected, percent); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); } @@ -202,7 +204,7 @@ class CommandOSAKill : public Command if (!x) return; - Log(LOG_ADMIN, source, this) << "to remove " << x->GetMask() << " from the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove {0} from the akill list"), x->GetMask()); ++deleted; x->Delete(); @@ -231,7 +233,8 @@ class CommandOSAKill : public Command { EventManager::Get()->Dispatch(&Event::DelXLine::OnDelXLine, source, x, akills); - Log(LOG_ADMIN, source, this) << "to remove " << x->GetMask() << " from the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove {0} from the akill list"), x->GetMask()); + source.Reply(_("\002{0}\002 deleted from the akill list."), x->GetMask()); x->Delete(); } @@ -345,7 +348,8 @@ class CommandOSAKill : public Command x->Delete(); } - Log(LOG_ADMIN, source, this) << "to CLEAR the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to CLEAR the akill list")); + source.Reply(_("The akill list has been cleared.")); if (Anope::ReadOnly) diff --git a/modules/operserv/chankill.cpp b/modules/operserv/chankill.cpp index 674200c84..32079f61d 100644 --- a/modules/operserv/chankill.cpp +++ b/modules/operserv/chankill.cpp @@ -109,7 +109,7 @@ class CommandOSChanKill : public Command akills->OnMatch(uc->user, x); } - Log(LOG_ADMIN, source, this) << "on " << c->name << " (" << realreason << ")"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to {0} ({1})"), c->name, realreason); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/operserv/config.cpp b/modules/operserv/config.cpp index 33ef0acef..2b6ce015d 100644 --- a/modules/operserv/config.cpp +++ b/modules/operserv/config.cpp @@ -52,7 +52,8 @@ class CommandOSConfig : public Command block->Set(params[2], params[3]); - Log(LOG_ADMIN, source, this) << "to change the configuration value of " << params[1] << ":" << params[2] << " to " << params[3]; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to change the configuration value of {0}:{1} to {2}"), + params[1], params[2], params[3]); source.Reply(_("Value of \002{0}:{1}\002 changed to \002{2}\002."), params[1], params[2], params[3]); } else if (what.equals_ci("VIEW")) @@ -60,7 +61,7 @@ class CommandOSConfig : public Command /* Blocks we should show */ const Anope::string show_blocks[] = { "serverinfo", "networkinfo", "options", "" }; - Log(LOG_ADMIN, source, this) << "VIEW"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to view the configuration")); for (unsigned i = 0; !show_blocks[i].empty(); ++i) { diff --git a/modules/operserv/defcon.cpp b/modules/operserv/defcon.cpp index e6839a3e8..3f24b2b63 100644 --- a/modules/operserv/defcon.cpp +++ b/modules/operserv/defcon.cpp @@ -108,7 +108,7 @@ struct DefconConfig static DefconConfig DConfig; -static void runDefCon(); +static void runDefCon(Module *module); static Anope::string defconReverseModes(const Anope::string &modes); static Timer *timeout; @@ -135,7 +135,8 @@ class DefConTimeout : public Timer { DConfig.defaultlevel = level; EventManager::Get()->Dispatch(&Event::DefconLevel::OnDefconLevel, level); - Log(Config->GetClient("OperServ"), "operserv/defcon") << "Defcon level timeout, returning to level " << level; + + this->GetOwner()->logger.Bot("OperServ").Category("operserv/defcon").Log(_("Defcon level timeout, returning to level {0}"), level); if (DConfig.globalondefcon && global) { @@ -148,7 +149,7 @@ class DefConTimeout : public Timer global->SendGlobal(NULL, "", DConfig.message); } - runDefCon(); + runDefCon(this->GetOwner()); } } }; @@ -223,7 +224,8 @@ class CommandOSDefcon : public Command source.Reply(_("Services are now at defcon \002{0}\002."), DConfig.defaultlevel); this->SendLevels(source); - Log(LOG_ADMIN, source, this) << "to change defcon level to " << newLevel; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to change defcon level to {0}"), newLevel); /* Global notice the user what is happening. Also any Message that the Admin would like to add. Set in config file. */ @@ -240,7 +242,7 @@ class CommandOSDefcon : public Command } /* Run any defcon functions, e.g. FORCE CHAN MODE */ - runDefCon(); + runDefCon(this->GetOwner()); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -299,7 +301,7 @@ class OSDefcon : public Module { if (cm->type == MODE_STATUS || cm->type == MODE_LIST) { - Log(this) << "DefConChanModes mode character '" << mode << "' cannot be locked"; + logger.Log("DefConChanModes mode character '{0}' cannot be locked", mode); continue; } else if (add) @@ -313,7 +315,7 @@ class OSDefcon : public Module if (!ss.GetToken(param)) { - Log(this) << "DefConChanModes mode character '" << mode << "' has no parameter while one is expected"; + logger.Log("DefConChanModes mode character '{0]' has no parameter while one is expected", mode); continue; } @@ -338,7 +340,7 @@ class OSDefcon : public Module { DConfig.DefConModesOn.erase("REDIRECT"); - Log(this) << "DefConChanModes must lock mode +l as well to lock mode +L"; + logger.Log("DefConChanModes must lock mode +l as well to lock mode +L"); } } @@ -517,7 +519,7 @@ class OSDefcon : public Module ServiceBot *OperServ = Config->GetClient("OperServ"); if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills) { - Log(OperServ, "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; + logger.Bot(OperServ).Category("operserv/defcon").Log("Adding akill for *@{0}", u->host); #warning "xline allocated on stack" #if 0 XLine x("*@" + u->host, OperServ ? OperServ->nick : "defcon", Anope::CurTime + DConfig.akillexpire, DConfig.akillreason, XLineManager::GenerateUID()); @@ -580,7 +582,7 @@ class OSDefcon : public Module } }; -static void runDefCon() +static void runDefCon(Module *module) { ServiceBot *OperServ = Config->GetClient("OperServ"); if (DConfig.Check(DEFCON_FORCE_CHAN_MODES)) @@ -589,7 +591,7 @@ static void runDefCon() { if (DConfig.chanmodes[0] == '+' || DConfig.chanmodes[0] == '-') { - Log(OperServ, "operserv/defcon") << "DEFCON: setting " << DConfig.chanmodes << " on all channels"; + module->logger.Bot(OperServ).Category("operserv/defcon").Log(_("Setting {0} on all channels"), DConfig.chanmodes); DefConModesSet = true; for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) it->second->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str()); @@ -606,7 +608,7 @@ static void runDefCon() Anope::string newmodes = defconReverseModes(DConfig.chanmodes); if (!newmodes.empty()) { - Log(OperServ, "operserv/defcon") << "DEFCON: setting " << newmodes << " on all channels"; + module->logger.Bot(OperServ).Category("operserv/defcon").Log(_("SSetting {0} on all channels"), newmodes); for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) it->second->SetModes(OperServ, true, "%s", newmodes.c_str()); } diff --git a/modules/operserv/dns.cpp b/modules/operserv/dns.cpp index 1ccb54530..8efa94fa9 100644 --- a/modules/operserv/dns.cpp +++ b/modules/operserv/dns.cpp @@ -383,7 +383,7 @@ class CommandOSDNS : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to add zone " << zone; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add zone {0}"), zone); DNSZone *z = Serialize::New(); z->SetName(zone); @@ -404,7 +404,7 @@ class CommandOSDNS : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to delete zone " << z->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to delete zone {0}"), z->GetName()); for (DNSZoneMembership *mem : z->GetRefs()) mem->Delete(); @@ -459,7 +459,7 @@ class CommandOSDNS : public Command manager->Notify(zone); } - Log(LOG_ADMIN, source, this) << "to add server " << s->GetName() << " to zone " << z->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add server {0} to zone {1}"), s->GetName(), z->GetName()); source.Reply(_("Server \002{0}\002 added to zone \002{1}\002."), s->GetName(), z->GetName()); } @@ -481,7 +481,8 @@ class CommandOSDNS : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to add server " << s->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add server {2}"), s->GetName()); + source.Reply(_("Added server \002{0}\002."), s->GetName()); } else @@ -497,7 +498,7 @@ class CommandOSDNS : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to add server " << s->GetName() << " to zone " << zone; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add server {0} to zone {1}"), s->GetName(), z->GetName()); DNSZoneMembership *mem = Serialize::New(); mem->SetServer(s); @@ -541,7 +542,7 @@ class CommandOSDNS : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to remove server " << s->GetName() << " from zone " << z->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove server {0} to zone {1}"), s->GetName(), z->GetName()); if (manager) { @@ -569,7 +570,8 @@ class CommandOSDNS : public Command if (manager) manager->UpdateSerial(); - Log(LOG_ADMIN, source, this) << "to delete server " << s->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to delete server {0}"), s->GetName()); + source.Reply(_("Removed server \002{0}\002."), s->GetName()); s->Delete(); } @@ -606,7 +608,8 @@ class CommandOSDNS : public Command ip->SetIP(params[2]); source.Reply(_("Added IP \002{0}\002 to \002{1}\002."), params[2], s->GetName()); - Log(LOG_ADMIN, source, this) << "to add IP " << params[2] << " to " << s->GetName(); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add IP {0} to {1}"), params[2], s->GetName()); if (s->Active() && manager) { @@ -635,7 +638,8 @@ class CommandOSDNS : public Command ip->Delete(); source.Reply(_("Removed IP \002{0}\002 from \002{1}\002."), params[2], s->GetName()); - Log(LOG_ADMIN, source, this) << "to remove IP " << params[2] << " from " << s->GetName(); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add IP {0} to {1}"), params[2], s->GetName()); if (s->GetRefs().empty()) { @@ -725,7 +729,8 @@ class CommandOSDNS : public Command s->SetActive(true); source.Reply(_("Pooled \002{0}\002."), s->GetName()); - Log(LOG_ADMIN, source, this) << "to pool " << s->GetName(); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to pool {0}"), s->GetName()); } @@ -751,7 +756,8 @@ class CommandOSDNS : public Command s->SetPool(false); source.Reply(_("Depooled \002{0}\002."), s->GetName()); - Log(LOG_ADMIN, source, this) << "to depool " << s->GetName(); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to depool {0}"), s->GetName()); } public: @@ -882,7 +888,7 @@ class ModuleDNS : public Module if (dns && dns->GetPooled() && !dns->Active() && !dns->GetRefs().empty()) { dns->SetActive(true); - Log(this) << "Pooling server " << s->GetName(); + logger.Log(_("Pooling server {0}"), s->GetName()); } } } @@ -896,7 +902,7 @@ class ModuleDNS : public Module dns->SetActive(false); // Will be reactivated when it comes back else dns->SetPool(false); // Otherwise permanently pull this - Log(this) << "Depooling delinked server " << s->GetName(); + logger.Log(_("Depooling delinked server {0}"), s->GetName()); } } @@ -908,7 +914,7 @@ class ModuleDNS : public Module /* Check for user limit reached */ if (s && s->GetPooled() && s->Active() && s->GetLimit() && u->server->users >= s->GetLimit()) { - Log(this) << "Depooling full server " << s->GetName() << ": " << u->server->users << " users"; + logger.Log(_("Depooling full server {0}: {1} users"), s->GetName(), u->server->users); s->SetActive(false); } } @@ -925,7 +931,7 @@ class ModuleDNS : public Module /* Check for dropping under userlimit */ if (s->GetLimit() && !s->Active() && s->GetLimit() > u->server->users) { - Log(this) << "Pooling server " << s->GetName(); + logger.Log(_("Pooling server {0}"), s->GetName()); s->SetActive(true); } @@ -943,7 +949,7 @@ class ModuleDNS : public Module /* Check for very fast user drops */ if (s->Active() && diff <= this->user_drop_time) { - Log(this) << "Depooling server " << s->GetName() << ": dropped " << this->user_drop_mark << " users in " << diff << " seconds"; + logger.Log(_("Depooling server {0}: dropped {1} users in {2} seconds"), s->GetName(), this->user_drop_mark, diff); s->repool = Anope::CurTime + this->user_drop_readd_time; s->SetActive(false); } @@ -952,7 +958,7 @@ class ModuleDNS : public Module { s->SetActive(true); s->repool = 0; - Log(this) << "Pooling server " << s->GetName(); + logger.Log(_("Pooling server {0}"), s->GetName()); } } } @@ -1020,7 +1026,7 @@ class ModuleDNS : public Module if (last_warn + 60 < Anope::CurTime) { last_warn = Anope::CurTime; - Log(this) << "Warning! There are no pooled servers!"; + logger.Log("Warning! There are no pooled servers!"); } /* Something messed up, just return them all and hope one is available */ @@ -1040,7 +1046,7 @@ class ModuleDNS : public Module if (packet->answers.size() == answer_size) { - Log(this) << "Error! There are no servers with any IPs of type " << q.type; + logger.Log("Error! There are no servers with any IPs of type {0}", q.type); /* Send back an empty answer anyway */ } } diff --git a/modules/operserv/forbid.cpp b/modules/operserv/forbid.cpp index bf38fc2ac..928aa2685 100644 --- a/modules/operserv/forbid.cpp +++ b/modules/operserv/forbid.cpp @@ -158,7 +158,7 @@ class MyForbidService : public ForbidService else if (d->GetType() == FT_EMAIL) ftype = "email"; - Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << d->GetMask() << " type " << ftype; + this->GetOwner()->logger.Bot("OperServ").Category("expire/forbid").Log(_("Expiring forbid for {0} type {1}"), d->GetMask(), ftype); d->Delete(); } return Serialize::GetObjects(); @@ -270,7 +270,8 @@ class CommandOSForbid : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to add a forbid on " << entry << " of type " << subcommand; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add a forbid on {0} of type {1}"), entry, subcommand); + source.Reply(_("Added a forbid on \002{0}\002 of type \002{1}\002 to expire on \002{2}\002."), entry, subcommand.lower(), expiryt ? Anope::strftime(expiryt, source.GetAccount()) : "never"); /* apply forbid */ @@ -381,7 +382,8 @@ class CommandOSForbid : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to remove forbid on " << d->GetMask() << " of type " << subcommand; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove forbid on {0} of type {1}"), d->GetMask(), subcommand); + source.Reply(_("\002{0}\002 deleted from the \002{1}\002 forbid list."), d->GetMask(), subcommand); d->Delete(); } diff --git a/modules/operserv/ignore.cpp b/modules/operserv/ignore.cpp index 397916ca4..afdd36837 100644 --- a/modules/operserv/ignore.cpp +++ b/modules/operserv/ignore.cpp @@ -155,7 +155,7 @@ class OSIgnoreService : public IgnoreService if (id->GetTime() && !Anope::NoExpire && id->GetTime() <= Anope::CurTime) { - Log(LOG_NORMAL, "expire/ignore", Config->GetClient("OperServ")) << "Expiring ignore entry " << id->GetMask(); + this->GetOwner()->logger.Bot("OperServ").Category("expire/ignore").Log(_("Expiring ignore for {0}"), id->GetMask()); id->Delete(); } else @@ -244,12 +244,14 @@ class CommandOSIgnore : public Command if (!t) { source.Reply(_("\002{0}\002 will now permanently be ignored."), mask); - Log(LOG_ADMIN, source, this) << "to add a permanent ignore for " << mask; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add a permanent ignore for {0}"), mask); } else { source.Reply(_("\002{0}\002 will now be ignored for \002{1}\002."), mask, Anope::Duration(t, source.GetAccount())); - Log(LOG_ADMIN, source, this) << "to add an ignore on " << mask << " for " << Anope::Duration(t); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add an ignore on {0} for {1}"), mask, Anope::Duration(t)); } } @@ -261,7 +263,7 @@ class CommandOSIgnore : public Command { if (id->GetTime() && !Anope::NoExpire && id->GetTime() <= Anope::CurTime) { - Log(LOG_NORMAL, "expire/ignore", Config->GetClient("OperServ")) << "Expiring ignore entry " << id->GetMask(); + this->GetOwner()->logger.Bot("OperServ").Category("expire/ignore").Log(_("Expiring ignore entry {0}"), id->GetMask()); id->Delete(); } } @@ -321,7 +323,8 @@ class CommandOSIgnore : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "to remove an ignore on " << mask; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove an ignore on {0}"), mask); + source.Reply(_("\002{0}\002 will no longer be ignored."), mask); ign->Delete(); } @@ -334,7 +337,8 @@ class CommandOSIgnore : public Command for (Ignore *ign : Serialize::GetObjects()) ign->Delete(); - Log(LOG_ADMIN, source, this) << "to CLEAR the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to CLEAR the ignore list")); + source.Reply(_("Ignore list has been cleared.")); } diff --git a/modules/operserv/info.cpp b/modules/operserv/info.cpp index c6038af5a..ff88a07d1 100644 --- a/modules/operserv/info.cpp +++ b/modules/operserv/info.cpp @@ -171,7 +171,8 @@ class CommandOSInfo : public Command o->SetCreated(Anope::CurTime); source.Reply(_("Added info to \002{0}\002."), target); - Log(LOG_ADMIN, source, this) << "to add information to " << target; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add oper information to {0}: {1}"), target, info); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); @@ -198,7 +199,8 @@ class CommandOSInfo : public Command o->Delete(); source.Reply(_("Deleted info from \002{0}\002."), target); - Log(LOG_ADMIN, source, this) << "to remove information from " << target; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove oper information from {0}: {1}"), target, info); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); @@ -222,7 +224,8 @@ class CommandOSInfo : public Command o->Delete(); source.Reply(_("Cleared info from \002{0}\002."), target); - Log(LOG_ADMIN, source, this) << "to clear information for " << target; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to clear oper information for {0}"), target); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); diff --git a/modules/operserv/jupe.cpp b/modules/operserv/jupe.cpp index 882effa4f..1d31ab1b4 100644 --- a/modules/operserv/jupe.cpp +++ b/modules/operserv/jupe.cpp @@ -42,7 +42,7 @@ class CommandOSJupe : public Command if (server == Me || server == Servers::GetUplink() || server->IsULined()) { - source.Reply(_("You can not jupe Servoces or its uplink server.")); + source.Reply(_("You can not jupe services, it's uplink, or any U:lined servers.")); return; } @@ -63,7 +63,7 @@ class CommandOSJupe : public Command Server *juped_server = new Server(Me, jserver, 1, rbuf, sid, true); IRCD->Send(juped_server); - Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} ({1}"), jserver, rbuf); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/operserv/kick.cpp b/modules/operserv/kick.cpp index 37e186156..ea9820dc2 100644 --- a/modules/operserv/kick.cpp +++ b/modules/operserv/kick.cpp @@ -60,7 +60,7 @@ class CommandOSKick : public Command return; } - Log(LOG_ADMIN, source, this) << "on " << u2->nick << " in " << c->name << " (" << s << ")"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} in {1} ({2})"), u2->nick, c->name, s); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/operserv/kill.cpp b/modules/operserv/kill.cpp index e4c97bcf4..42571bc10 100644 --- a/modules/operserv/kill.cpp +++ b/modules/operserv/kill.cpp @@ -50,7 +50,9 @@ class CommandOSKill : public Command reason = "No reason specified"; if (Config->GetModule("operserv/main")->Get("addakiller")) reason = "(" + source.GetNick() + ") " + reason; - Log(LOG_ADMIN, source, this) << "on " << u2->nick << " for " << reason; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} for {1}"), u2->nick, reason); + u2->Kill(*source.service, reason); } diff --git a/modules/operserv/list.cpp b/modules/operserv/list.cpp index 00b7bf746..e149c7e4b 100644 --- a/modules/operserv/list.cpp +++ b/modules/operserv/list.cpp @@ -36,9 +36,9 @@ class CommandOSChanList : public Command User *u2; if (!pattern.empty()) - Log(LOG_ADMIN, source, this) << "for " << pattern; + logger.Command(LogType::ADMIN, source, _("{source} used {command} for {0}"), pattern); else - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); if (!opt.empty() && opt.equals_ci("SECRET")) { @@ -138,9 +138,9 @@ class CommandOSUserList : public Command std::set modes; if (!pattern.empty()) - Log(LOG_ADMIN, source, this) << "for " << pattern; + logger.Command(LogType::ADMIN, source, _("{source} used {command} for {0}"), pattern); else - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); if (!opt.empty() && opt.equals_ci("INVISIBLE")) modes.insert("INVIS"); diff --git a/modules/operserv/login.cpp b/modules/operserv/login.cpp index 270958875..f9dcdd38f 100644 --- a/modules/operserv/login.cpp +++ b/modules/operserv/login.cpp @@ -59,7 +59,8 @@ class CommandOSLogin : public Command return; } - Log(LOG_ADMIN, source, this) << "and successfully identified to " << source.service->nick; + logger.Command(LogType::ADMIN, source, _("{source} used {command} and successfully identified to {0}"), source.service->nick); + u->Extend("os_login", true); source.Reply(_("Password accepted.")); } @@ -106,7 +107,8 @@ class CommandOSLogout : public Command return; } - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); + u->Shrink("os_login"); source.Reply(_("You have been logged out.")); } diff --git a/modules/operserv/logsearch.cpp b/modules/operserv/logsearch.cpp index d9dc7b891..702abe0e0 100644 --- a/modules/operserv/logsearch.cpp +++ b/modules/operserv/logsearch.cpp @@ -95,14 +95,16 @@ class CommandOSLogSearch : public Command for (; i < params.size(); ++i) search_string += " " + params[i]; - Log(LOG_ADMIN, source, this) << "for " << search_string; + logger.Command(LogType::ADMIN, source, _("{source} used {command} for {2}"), search_string); const Anope::string &logfile_name = Config->GetModule(this->GetOwner())->Get("logname"); std::list matches; for (int d = days - 1; d >= 0; --d) { Anope::string lf_name = CreateLogName(logfile_name, Anope::CurTime - (d * 86400)); - Log(LOG_DEBUG) << "Searching " << lf_name; + + this->logger.Debug("Searching {0}", lf_name); + std::fstream fd(lf_name.c_str(), std::ios_base::in); if (!fd.is_open()) continue; diff --git a/modules/operserv/main/operserv.cpp b/modules/operserv/main/operserv.cpp index fc8dbf423..93c106497 100644 --- a/modules/operserv/main/operserv.cpp +++ b/modules/operserv/main/operserv.cpp @@ -33,7 +33,8 @@ class SGLineManager : public XLineManager void OnExpire(XLine *x) override { - ::Log(Config->GetClient("OperServ"), "expire/akill") << "AKILL on \002" << x->GetMask() << "\002 has expired"; + Anope::Logger.Bot("OperServ").Category("expire/akill").Log(_("AKILL on \002{0}\002 has expired"), + x->GetMask()); } void Send(User *u, XLine *x) override @@ -85,7 +86,7 @@ class SQLineManager : public XLineManager void OnExpire(XLine *x) override { - ::Log(Config->GetClient("OperServ"), "expire/sqline") << "SQLINE on \002" << x->GetMask() << "\002 has expired"; + Anope::Logger.Bot("OperServ").Category("expire/sqline").Log(_("SQLINE on \002{0}\002 has expired"), x->GetMask()); } void Send(User *u, XLine *x) override @@ -162,7 +163,7 @@ class SNLineManager : public XLineManager void OnExpire(XLine *x) override { - ::Log(Config->GetClient("OperServ"), "expire/snline") << "SNLINE on \002" << x->GetMask() << "\002 has expired"; + Anope::Logger.Bot("OperServ").Category("expire/snline").Log(_("SNLINE on \002{0}\002 has expired"), x->GetMask()); } void Send(User *u, XLine *x) override @@ -255,8 +256,8 @@ class OperServCore : public Module { if (bi == OperServ && !u->HasMode("OPER") && Config->GetModule(this)->Get("opersonly")) { - u->SendMessage(bi, "Access denied."); - ::Log(bi, "bados") << "Denied access to " << bi->nick << " from " << u->GetMask() << " (non-oper)"; + u->SendMessage(bi, _("Access denied.")); + logger.Bot(bi).Category("bados").Log(_("Denied access to {0} from {1} (non-oper)"), bi->nick, u->GetMask()); return EVENT_STOP; } @@ -266,19 +267,19 @@ class OperServCore : public Module void OnServerQuit(Server *server) override { if (server->IsJuped()) - ::Log(server, "squit", OperServ) << "Received SQUIT for juped server " << server->GetName(); + server->logger.Bot(OperServ).Category("squit").Log(_("Received SQUIT for juped server {0}"), server->GetName()); } void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override { if (mname == "OPER") - ::Log(u, "oper", OperServ) << "is now an IRC operator."; + u->logger.Bot(OperServ).Category("oper").Log(_("{0} is now an IRC operator."), u->GetMask()); } void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) override { if (mname == "OPER") - ::Log(u, "oper", OperServ) << "is no longer an IRC operator"; + u->logger.Bot(OperServ).Category("oper").Log(_("{0} is no longer an IRC operator"), u->GetMask()); } void OnUserConnect(User *u, bool &exempt) override @@ -310,7 +311,8 @@ class OperServCore : public Module { if (!params.empty() || source.c || source.service != *OperServ) return EVENT_CONTINUE; - source.Reply(_("%s commands:"), OperServ->nick.c_str()); + + source.Reply(_("{0} commands:"), OperServ->nick); return EVENT_CONTINUE; } @@ -318,10 +320,13 @@ class OperServCore : public Module { } - void OnLog(::Log *l) override + void OnLog(Logger *l) override { - if (l->type == LOG_SERVER) +#warning "" +#if 0 + if (l->type == LogType::SERVER) l->bi = OperServ; +#endif } }; diff --git a/modules/operserv/mode.cpp b/modules/operserv/mode.cpp index a66f8897f..6e7e0e157 100644 --- a/modules/operserv/mode.cpp +++ b/modules/operserv/mode.cpp @@ -140,7 +140,7 @@ class CommandOSMode : public Command } if (!log_modes.replace_all_cs("+", "").replace_all_cs("-", "").empty()) - Log(LOG_ADMIN, source, this) << log_modes << log_params << " on " << (c ? c->name : target); + logger.Command(LogType::ADMIN, source, _("{source} used {command} {0} on {1}"), log_modes + log_params, c ? c->name : target); } } @@ -169,16 +169,17 @@ class CommandOSUMode : public Command User *u2 = User::Find(target, true); if (!u2) - source.Reply(_("\002{0}\002 isn't currently online."), target); - else { - u2->SetModes(source.service, "%s", modes.c_str()); - source.Reply(_("Changed usermodes of \002{0}\002 to \002{1}\002."), u2->nick.c_str(), modes.c_str()); + source.Reply(_("\002{0}\002 isn't currently online."), target); + return; + } - u2->SendMessage(*source.service, _("\002{0}\002 changed your usermodes to \002{1}\002."), source.GetNick(), modes); + u2->SetModes(source.service, "%s", modes.c_str()); + source.Reply(_("Changed usermodes of \002{0}\002 to \002{1}\002."), u2->nick.c_str(), modes.c_str()); - Log(LOG_ADMIN, source, this) << modes << " on " << target; - } + u2->SendMessage(*source.service, _("\002{0}\002 changed your usermodes to \002{1}\002."), source.GetNick(), modes); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0}"), target); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/operserv/modinfo.cpp b/modules/operserv/modinfo.cpp index cd926d1e5..e1860583c 100644 --- a/modules/operserv/modinfo.cpp +++ b/modules/operserv/modinfo.cpp @@ -32,7 +32,7 @@ class CommandOSModInfo : public Command { const Anope::string &file = params[0]; - Log(LOG_ADMIN, source, this) << "on " << file; + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0}"), file); Module *m = ModuleManager::FindModule(file); if (m == nullptr) @@ -95,9 +95,10 @@ class CommandOSModList : public Command const Anope::string ¶m = !params.empty() ? params[0] : ""; if (!param.empty()) - Log(LOG_ADMIN, source, this) << "for " << param; + logger.Command(LogType::ADMIN, source, _("{source} used {command} for {0}"), param); else - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}"), + source.GetSource(), source.GetCommand()); bool third = false, vendor = false, extra = false, database = false, encryption = false, pseudoclient = false, protocol = false; diff --git a/modules/operserv/module.cpp b/modules/operserv/module.cpp index 1e4e0bac5..669638a51 100644 --- a/modules/operserv/module.cpp +++ b/modules/operserv/module.cpp @@ -35,7 +35,7 @@ class CommandOSModLoad : public Command ModuleReturn status = ModuleManager::LoadModule(mname, source.GetUser()); if (status == MOD_ERR_OK) { - Log(LOG_ADMIN, source, this) << "to load module " << mname; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to load module {0}"), mname); source.Reply(_("Module \002{0}\002 loaded."), mname); } else if (status == MOD_ERR_EXISTS) @@ -101,7 +101,7 @@ class CommandOSModReLoad : public Command status = ModuleManager::LoadModule(mname, source.GetUser()); if (status == MOD_ERR_OK) { - Log(LOG_ADMIN, source, this) << "to reload module " << mname; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to reload module {0}"), mname); source.Reply(_("Module \002{0}\002 reloaded."), mname); } else @@ -151,13 +151,11 @@ class CommandOSModUnLoad : public Command return; } - Log(this->GetOwner()) << "Trying to unload module [" << mname << "]"; - ModuleReturn status = ModuleManager::UnloadModule(m, source.GetUser()); if (status == MOD_ERR_OK) { - Log(LOG_ADMIN, source, this) << "to unload module " << mname; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to unload module {0}"), mname); source.Reply(_("Module \002{0}\002 unloaded."), mname); } else diff --git a/modules/operserv/news.cpp b/modules/operserv/news.cpp index e2119a2de..3a829f0c3 100644 --- a/modules/operserv/news.cpp +++ b/modules/operserv/news.cpp @@ -220,7 +220,8 @@ class NewsBase : public Command ni->SetWho(source.GetNick()); source.Reply(msgs[MSG_ADDED]); - Log(LOG_ADMIN, source, this) << "to add a news item"; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add news item: {0}"), text); } void DoDel(CommandSource &source, const std::vector ¶ms, NewsType ntype, const char **msgs) @@ -250,9 +251,13 @@ class NewsBase : public Command unsigned num = convertTo(text); if (num > 0 && num <= list.size()) { - list[num - 1]->Delete(); + NewsItem *item = list[num - 1]; source.Reply(msgs[MSG_DELETED], num); - Log(LOG_ADMIN, source, this) << "to delete a news item"; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to delete news item {0}"), item->GetText()); + + item->Delete(); + return; } } @@ -265,7 +270,8 @@ class NewsBase : public Command for (NewsItem *n : list) n->Delete(); source.Reply(msgs[MSG_DELETED_ALL]); - Log(LOG_ADMIN, source, this) << "to delete all news items"; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to delete all news items")); } } diff --git a/modules/operserv/noop.cpp b/modules/operserv/noop.cpp index 329a6c338..ce3ce9f9b 100644 --- a/modules/operserv/noop.cpp +++ b/modules/operserv/noop.cpp @@ -53,7 +53,8 @@ class CommandOSNOOP : public Command IRCD->Send(s, true); s->Extend("noop", source.GetNick()); - Log(LOG_ADMIN, source, this) << "SET on " << s->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0}"), s->GetName()); + source.Reply(_("All operators from \002{0}\002 have been removed."), s->GetName()); Anope::string reason = "NOOP command used by " + source.GetNick(); @@ -70,7 +71,9 @@ class CommandOSNOOP : public Command { s->Shrink("noop"); IRCD->Send(s, false); - Log(LOG_ADMIN, source, this) << "REVOKE on " << s->GetName(); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} REVOKE on {0}"), s->GetName()); + source.Reply(_("All O:lines of \002{0}\002 have been reset."), s->GetName()); } else diff --git a/modules/operserv/oper.cpp b/modules/operserv/oper.cpp index 099cfc286..00c7e0f4d 100644 --- a/modules/operserv/oper.cpp +++ b/modules/operserv/oper.cpp @@ -97,7 +97,8 @@ class CommandOSOper : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "ADD " << na->GetNick() << " as type " << ot->GetName(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to add {0} as an oper of type {1}"), na->GetNick(), ot->GetName()); + source.Reply("\002{0}\002 (\002{1}\002) added to the \002{2}\002 list.", na->GetNick(), na->GetAccount()->GetDisplay(), ot->GetName()); } else if (subcommand.equals_ci("DEL") && params.size() > 1) @@ -137,7 +138,8 @@ class CommandOSOper : public Command if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); - Log(LOG_ADMIN, source, this) << "DEL " << na->GetNick(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove {0}"), na->GetNick()); + source.Reply(_("Oper privileges removed from \002{0}\002 (\002{1}\002)."), na->GetNick(), na->GetAccount()->GetDisplay()); } else if (subcommand.equals_ci("LIST")) diff --git a/modules/operserv/reload.cpp b/modules/operserv/reload.cpp index ecff66ac2..fa79cd0d7 100644 --- a/modules/operserv/reload.cpp +++ b/modules/operserv/reload.cpp @@ -31,7 +31,7 @@ class CommandOSReload : public Command { try { - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); Configuration::Conf *new_config = new Configuration::Conf(); Configuration::Conf *old = Config; @@ -43,7 +43,7 @@ class CommandOSReload : public Command } catch (const ConfigException &ex) { - Log(this->GetOwner()) << "Error reloading configuration file: " << ex.GetReason(); + this->GetOwner()->logger.Log(_("Error reloading configuration file: {0}"), ex.GetReason()); source.Reply(_("Error reloading configuration file: {0}"), ex.GetReason()); } } diff --git a/modules/operserv/session.cpp b/modules/operserv/session.cpp index cdd230473..cb22f65b9 100644 --- a/modules/operserv/session.cpp +++ b/modules/operserv/session.cpp @@ -303,7 +303,7 @@ class CommandOSSession : public Command { const Anope::string &cmd = params[0]; - Log(LOG_ADMIN, source, this) << cmd << " " << params[1]; + logger.Command(LogType::ADMIN, source, _("{source} used {command} {0} {1}"), cmd, params[1]); if (!session_limit) source.Reply(_("Session limiting is disabled.")); @@ -422,7 +422,8 @@ class CommandOSException : public Command if (MOD_RESULT == EVENT_STOP) return; - Log(LOG_ADMIN, source, this) << "to set the session limit for " << mask << " to " << limit; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to set the session limit for {0} to {1}"), mask, limit); + source.Reply(_("Session limit for \002{0}\002 set to \002{1}\002."), mask, limit); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); @@ -452,7 +453,7 @@ class CommandOSException : public Command Exception *e = exceptions[number - 1]; - Log(LOG_ADMIN, source, this) << "to remove the session limit exception for " << e->GetMask(); + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove the session limit exception for {0}"), e->GetMask()); ++deleted; DoDel(source, e); @@ -473,7 +474,8 @@ class CommandOSException : public Command for (Exception *e : Serialize::GetObjects()) if (mask.equals_ci(e->GetMask())) { - Log(LOG_ADMIN, source, this) << "to remove the session limit exception for " << mask; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove the session limit exception for {0}"), e->GetMask()); + DoDel(source, e); source.Reply(_("\002{0}\002 deleted from session-limit exception list."), mask); found = true; @@ -728,7 +730,7 @@ class OSSession : public Module akills->AddXLine(x); akills->Send(NULL, x); - Log(OperServ, "akill/session") << "Added a temporary AKILL for \002" << akillmask << "\002 due to excessive connections"; + logger.Bot(OperServ).Category("akill/session").Log(_("Added a temporary AKILL for \002{0}\002 due to excessive connections"), akillmask); } else { @@ -776,7 +778,7 @@ class OSSession : public Module continue; ServiceBot *OperServ = Config->GetClient("OperServ"); - Log(OperServ, "expire/exception") << "Session exception for " << e->GetMask() << " has expired."; + logger.Bot(OperServ).Category("expire/exception").Log(_("Session exception for {0} has expired."), e->GetMask()); e->Delete(); } } diff --git a/modules/operserv/set.cpp b/modules/operserv/set.cpp index e23efb849..f8a63dca8 100644 --- a/modules/operserv/set.cpp +++ b/modules/operserv/set.cpp @@ -24,7 +24,7 @@ class CommandOSSet : public Command private: void DoList(CommandSource &source) { - Log(LOG_ADMIN, source, this) << "LIST"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} LIST")); const char *str; @@ -51,13 +51,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { Anope::ReadOnly = true; - Log(LOG_ADMIN, source, this) << "READONLY ON"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} READONLY ON")); source.Reply(_("Services are now in \002read-only\002 mode.")); } else if (setting.equals_ci("OFF")) { Anope::ReadOnly = false; - Log(LOG_ADMIN, source, this) << "READONLY OFF"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} READONLY OFF")); source.Reply(_("Services are now in \002read-write\002 mode.")); } else @@ -95,13 +95,15 @@ class CommandOSSet : public Command { source.GetUser()->super_admin = true; source.Reply(_("You are now a super admin.")); - Log(LOG_ADMIN, source, this) << "SUPERADMIN ON"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} SUPERADMIN ON"), + source.GetSource(), source.GetCommand()); } else if (setting.equals_ci("OFF")) { source.GetUser()->super_admin = false; source.Reply(_("You are no longer a super admin.")); - Log(LOG_ADMIN, source, this) << "SUPERADMIN OFF"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} SUPERADMIN OFF"), + source.GetSource(), source.GetCommand()); } else { @@ -122,12 +124,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { Anope::Debug = 1; - Log(LOG_ADMIN, source, this) << "DEBUG ON"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} DEBUG ON"), + source.GetSource(), source.GetCommand()); source.Reply(_("Services are now in \002debug\002 mode.")); } else if (setting.equals_ci("OFF") || setting == "0") { - Log(LOG_ADMIN, source, this) << "DEBUG OFF"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} DEBUG OFF")); Anope::Debug = 0; source.Reply(_("Services are now in \002non-debug\002 mode.")); } @@ -136,7 +139,7 @@ class CommandOSSet : public Command try { Anope::Debug = convertTo(setting); - Log(LOG_ADMIN, source, this) << "DEBUG " << Anope::Debug; + logger.Command(LogType::ADMIN, source, _("{source} used {command} DEBUG {0}"), Anope::Debug); source.Reply(_("Services are now in \002debug\002 mode (level %d)."), Anope::Debug); return; } @@ -159,13 +162,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { Anope::NoExpire = true; - Log(LOG_ADMIN, source, this) << "NOEXPIRE ON"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} NOEXPIRE ON"), Anope::Debug); source.Reply(_("Services are now in \002no expire\002 mode.")); } else if (setting.equals_ci("OFF")) { Anope::NoExpire = false; - Log(LOG_ADMIN, source, this) << "NOEXPIRE OFF"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} NOEXPIRE OFF"), Anope::Debug); source.Reply(_("Services are now in \002expire\002 mode.")); } else diff --git a/modules/operserv/shutdown.cpp b/modules/operserv/shutdown.cpp index 030eb73f4..de987537f 100644 --- a/modules/operserv/shutdown.cpp +++ b/modules/operserv/shutdown.cpp @@ -29,7 +29,7 @@ class CommandOSRestart : public Command void Execute(CommandSource &source, const std::vector ¶ms) override { - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); Anope::QuitReason = source.command + " command received from " + source.GetNick(); Anope::Quitting = Anope::Restarting = true; } @@ -51,7 +51,7 @@ class CommandOSShutdown : public Command void Execute(CommandSource &source, const std::vector ¶ms) override { - Log(LOG_ADMIN, source, this); + logger.Command(LogType::ADMIN, source, _("{source} used {command}")); Anope::QuitReason = source.command + " command received from " + source.GetNick(); Anope::Quitting = true; } diff --git a/modules/operserv/stats.cpp b/modules/operserv/stats.cpp index abee79cf6..e9df4cf83 100644 --- a/modules/operserv/stats.cpp +++ b/modules/operserv/stats.cpp @@ -246,7 +246,7 @@ class CommandOSStats : public Command { Anope::string extra = !params.empty() ? params[0] : ""; - Log(LOG_ADMIN, source, this) << extra; + logger.Command(LogType::ADMIN, source, _("{source} used {command} {0}"), extra); if (extra.equals_ci("RESET")) return this->DoStatsReset(source); @@ -318,7 +318,7 @@ class OSStats : public Module Server *sserver = u->server; if (sserver && sserver->IsSynced()) - Log(this, "maxusers") << "connected - new maximum user count: " << UserListByNick.size(); + u->logger.Category("maxusers").Log(_("{0} connected - new maximum user count: {1}"), u->GetMask(), UserListByNick.size()); } } }; diff --git a/modules/operserv/svs.cpp b/modules/operserv/svs.cpp index ccba9d8d1..40d37a5d7 100644 --- a/modules/operserv/svs.cpp +++ b/modules/operserv/svs.cpp @@ -68,7 +68,9 @@ class CommandOSSVSNick : public Command } source.Reply(_("\002{0}\002 is now being changed to \002{1}\002."), nick, newnick); - Log(LOG_ADMIN, source, this) << "to change " << nick << " to " << newnick; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to change {0} to {1}"), u2->nick, newnick); + IRCD->Send(u2, newnick, Anope::CurTime); } @@ -123,7 +125,9 @@ class CommandOSSVSJoin : public Command } IRCD->Send(*source.service, target, params[1], ""); - Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to join " << params[1]; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to force {0} to join {1}"), target->nick, params[1]); + source.Reply(_("\002{0}\002 has been joined to \002{1}\002."), target->nick, params[1]); } @@ -178,11 +182,16 @@ class CommandOSSVSPart : public Command } const Anope::string &reason = params.size() > 2 ? params[2] : ""; + IRCD->Send(*source.service, target, params[1], reason); + if (!reason.empty()) - Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to part " << c->name << " with reason " << reason; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to force {0} to part {1} with reason {2}"), + target->nick, c->name, reason); else - Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to part " << c->name; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to force {0} to part {1}"), + target->nick, c->name); + source.Reply(_("\002{0}\002 has been parted from \002{1}\002."), target->nick, c->name); } diff --git a/modules/operserv/sxline.cpp b/modules/operserv/sxline.cpp index 2c98805f2..47133c16e 100644 --- a/modules/operserv/sxline.cpp +++ b/modules/operserv/sxline.cpp @@ -54,7 +54,7 @@ class CommandOSSXLineBase : public Command if (!x) return; - Log(LOG_ADMIN, source, this) << "to remove " << x->GetMask() << " from the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove {0} from the list"), x->GetMask()); ++deleted; x->Delete(); @@ -81,9 +81,11 @@ class CommandOSSXLineBase : public Command EventManager::Get()->Dispatch(&Event::DelXLine::OnDelXLine, source, x, this->xlm()); + source.Reply(_("\002{0}\002 deleted from the {1} list."), x->GetMask(), source.command); + + logger.Command(LogType::ADMIN, source, _("{source} used {command} to remove {0} from the list"), x->GetMask()); + x->Delete(); - source.Reply(_("\002{0}\002 deleted from the {1} list."), mask, source.command); - Log(LOG_ADMIN, source, this) << "to remove " << mask << " from the list"; } if (Anope::ReadOnly) @@ -184,7 +186,8 @@ class CommandOSSXLineBase : public Command for (XLine *x : this->xlm()->GetXLines()) x->Delete(); - Log(LOG_ADMIN, source, this) << "to CLEAR the list"; + logger.Command(LogType::ADMIN, source, _("{source} used {command} to CLEAR the list")); + source.Reply(_("The {0} list has been cleared."), source.command); if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); @@ -342,8 +345,11 @@ class CommandOSSNLine : public CommandOSSXLineBase if (percent > 95) { source.Reply(_("\002{0}\002 coverage is too wide; please use a more specific mask."), mask); - Log(LOG_ADMIN, source, this) << "tried to " << source.command << " " << percent << "% of the network (" << affected << " users)"; - delete x; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} and tried to {0} {1}% of the network ({2} users)"), + source.command, percent, affected); + + x->Delete(); return; } @@ -351,7 +357,7 @@ class CommandOSSNLine : public CommandOSSXLineBase MOD_RESULT = EventManager::Get()->Dispatch(&Event::AddXLine::OnAddXLine, source, x, this->xlm()); if (MOD_RESULT == EVENT_STOP) { - delete x; + x->Delete(); return; } @@ -373,7 +379,11 @@ class CommandOSSNLine : public CommandOSSXLineBase } source.Reply(_("\002{0}\002 added to the {1} list."), mask, source.command); - Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << "), expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} ({1}), expires in {2} [affects {3} user(s) ({4}%)]"), + mask, reason, expires ? Anope::Duration(expires - Anope::CurTime) : "never", + affected, percent); + if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); } @@ -560,8 +570,10 @@ class CommandOSSQLine : public CommandOSSXLineBase if (percent > 95) { source.Reply(_("\002{0}\002 coverage is too wide; please use a more specific mask."), mask); - Log(LOG_ADMIN, source, this) << "tried to SQLine " << percent << "% of the network (" << affected << " users)"; - delete x; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} and tried to {0} {1}% of the network ({2} users)"), source.command, percent, affected); + + x->Delete(); return; } @@ -569,7 +581,7 @@ class CommandOSSQLine : public CommandOSSXLineBase MOD_RESULT = EventManager::Get()->Dispatch(&Event::AddXLine::OnAddXLine, source, x, this->xlm()); if (MOD_RESULT == EVENT_STOP) { - delete x; + x->Delete(); return; } @@ -617,7 +629,10 @@ class CommandOSSQLine : public CommandOSSXLineBase } source.Reply(_("\002{0}\002 added to the {1} list."), mask, source.command); - Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << "), expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + + logger.Command(LogType::ADMIN, source, _("{source} used {command} on {0} ({1}), expires in {2} [affects {3} user(s) ({4}%)]"), + mask, x->GetReason(), expires ? Anope::Duration(expires - Anope::CurTime) : "never", affected, percent); + if (Anope::ReadOnly) source.Reply(_("Services are in read-only mode. Any changes made may not persist.")); } -- cgit