summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bots.cpp6
-rw-r--r--src/channels.cpp67
-rw-r--r--src/command.cpp39
-rw-r--r--src/config.cpp16
-rw-r--r--src/extensible.cpp2
-rw-r--r--src/init.cpp100
-rw-r--r--src/language.cpp17
-rw-r--r--src/logger.cpp445
-rw-r--r--src/mail.cpp4
-rw-r--r--src/main.cpp11
-rw-r--r--src/misc.cpp43
-rw-r--r--src/modes.cpp12
-rw-r--r--src/module.cpp20
-rw-r--r--src/modulemanager.cpp42
-rw-r--r--src/process.cpp22
-rw-r--r--src/serialize.cpp32
-rw-r--r--src/servers.cpp16
-rw-r--r--src/service_manager.cpp8
-rw-r--r--src/socket_clients.cpp8
-rw-r--r--src/socketengines/socketengine_epoll.cpp2
-rw-r--r--src/socketengines/socketengine_kqueue.cpp2
-rw-r--r--src/socketengines/socketengine_poll.cpp2
-rw-r--r--src/socketengines/socketengine_select.cpp2
-rw-r--r--src/sockets.cpp2
-rw-r--r--src/uplink.cpp30
-rw-r--r--src/users.cpp36
-rw-r--r--src/xline.cpp2
27 files changed, 573 insertions, 415 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index dfe46ea67..86d0a0136 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -31,11 +31,13 @@
#include "event.h"
#include "modules/chanserv.h"
-ServiceBot::ServiceBot(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : LocalUser(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", IRCD ? IRCD->UID_Retrieve() : "", NULL), botmodes(bmodes)
+ServiceBot::ServiceBot(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes)
+ : LocalUser(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", IRCD ? IRCD->UID_Retrieve() : "", NULL)
+ , botmodes(bmodes)
+ , logger(this)
{
this->type = UserType::BOT;
this->lastmsg = Anope::CurTime;
- this->introduced = false;
EventManager::Get()->Dispatch(&Event::CreateBot::OnCreateBot, this);
diff --git a/src/channels.cpp b/src/channels.cpp
index aed6c7b53..2b9ea438d 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -36,19 +36,16 @@ channel_map ChannelList;
std::vector<Channel *> Channel::deleting;
Channel::Channel(const Anope::string &nname, time_t ts)
+ : logger(this)
{
if (nname.empty())
throw CoreException("A channel without a name ?");
this->name = nname;
-
this->creation_time = ts;
- this->syncing = this->botchannel = false;
- this->server_modetime = this->chanserv_modetime = 0;
- this->server_modecount = this->chanserv_modecount = this->bouncy_modes = this->topic_ts = this->topic_time = 0;
if (Me && Me->IsSynced())
- Log(NULL, this, "create");
+ logger.Category("create").Log("Channel {0} was created", this->GetName());
EventManager::Get()->Dispatch(&Event::ChannelCreate::OnChannelCreate, this);
}
@@ -60,7 +57,7 @@ Channel::~Channel()
ModeManager::StackerDel(this);
if (Me && Me->IsSynced())
- Log(NULL, this, "destroy");
+ logger.Category("destroy").Log("Channel {0} was destroyed", this->GetName());
if (this->ci)
this->ci->c = NULL;
@@ -68,6 +65,11 @@ Channel::~Channel()
ChannelList.erase(this->name);
}
+const Anope::string &Channel::GetName() const
+{
+ return name;
+}
+
void Channel::Reset()
{
this->modes.clear();
@@ -113,7 +115,7 @@ void Channel::CheckModes()
/* Check for mode bouncing */
if (this->chanserv_modetime == Anope::CurTime && this->server_modetime == Anope::CurTime && this->server_modecount >= 3 && this->chanserv_modecount >= 3)
{
- Log() << "Warning: unable to set modes on channel " << this->name << ". Are your servers' U:lines configured correctly?";
+ Anope::Logger.Log("Warning: unable to set modes on channel {0}. Are your servers' U:lines configured correctly?", this->GetName());
this->bouncy_modes = 1;
return;
}
@@ -143,7 +145,7 @@ bool Channel::CheckDelete()
ChanUserContainer* Channel::JoinUser(User *user, const ChannelStatus *status)
{
if (user->server && user->server->IsSynced())
- Log(user, this, "join");
+ logger.Category("join").Log(_("{0} joined {1}"), user->GetMask(), this->GetName());
ChanUserContainer *cuc = new ChanUserContainer(user, this);
user->chans[this] = cuc;
@@ -157,16 +159,16 @@ ChanUserContainer* Channel::JoinUser(User *user, const ChannelStatus *status)
void Channel::DeleteUser(User *user)
{
if (user->server && user->server->IsSynced() && !user->Quitting())
- Log(user, this, "leave");
+ logger.Category("leave").Log(_("{0} left {1}"), user->GetMask(), this->GetName());
EventManager::Get()->Dispatch(&Event::LeaveChannel::OnLeaveChannel, user, this);
ChanUserContainer *cu = user->FindChannel(this);
if (!this->users.erase(user))
- Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete non-existent user " << user->nick << " from channel " << this->name;
+ logger.Debug("Channel::DeleteUser() tried to delete non-existent user {0} from channel {1}", user->GetMask(), this->GetName());
if (!user->chans.erase(this))
- Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete non-existent channel " << this->name << " from " << user->nick << "'s channel list";
+ logger.Debug("Channel::DeleteUser() tried to delete non-existent channel {0} from channel list of user {1}", this->GetName(), user->GetMask());
delete cu;
QueueForDeletion();
@@ -273,7 +275,7 @@ void Channel::SetModeInternal(const MessageSource &setter, ChannelMode *ocm, con
{
if (param.empty())
{
- Log() << "Channel::SetModeInternal() mode " << cm->mchar << " with no parameter for channel " << this->name;
+ Anope::Logger.Log("Channel::SetModeInternal() mode {} with no parameter for channel {}", cm->mchar, this->GetName());
return;
}
@@ -281,11 +283,11 @@ void Channel::SetModeInternal(const MessageSource &setter, ChannelMode *ocm, con
if (!u)
{
- Log() << "MODE " << this->name << " +" << cm->mchar << " for non-existent user " << param;
+ Anope::Logger.Debug("Mode +{0} for non-existent user {1} on channel {2}", cm->mchar, param, this->GetName());
return;
}
- Log(LOG_DEBUG) << "Setting +" << cm->mchar << " on " << this->name << " for " << u->nick;
+ Anope::Logger.Debug("Setting +{0} on {1} for {2}", cm->mchar, this->GetName(), u->GetMask());
/* Set the status on the user */
ChanUserContainer *cc = u->FindChannel(this);
@@ -309,7 +311,7 @@ void Channel::SetModeInternal(const MessageSource &setter, ChannelMode *ocm, con
if (param.empty() && cm->type != MODE_REGULAR)
{
- Log() << "Channel::SetModeInternal() mode " << cm->mchar << " for " << this->name << " with no paramater, but is a param mode";
+ Anope::Logger.Log("Channel::SetModeInternal() mode {0} for {1} with no paramater, but is a param mode", cm->mchar, this->name);
return;
}
@@ -337,7 +339,7 @@ void Channel::RemoveModeInternal(const MessageSource &setter, ChannelMode *ocm,
{
if (param.empty())
{
- Log() << "Channel::RemoveModeInternal() mode " << cm->mchar << " with no parameter for channel " << this->name;
+ Anope::Logger.Log("Channel::RemoveModeInternal() mode {0} with no parameter for channel {1}", cm->mchar, this->GetName());
return;
}
@@ -345,11 +347,11 @@ void Channel::RemoveModeInternal(const MessageSource &setter, ChannelMode *ocm,
if (!u)
{
- Log() << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->mchar << " for non-existent user " << param;
+ Anope::Logger.Debug("Mode -{0} for non-existent user {1} on channel {2}", cm->mchar, param, this->GetName());
return;
}
- Log(LOG_DEBUG) << "Setting -" << cm->mchar << " on " << this->name << " for " << u->nick;
+ Anope::Logger.Debug("Setting -{0} on {1} for {2}", cm->mchar, this->GetName(), u->GetMask());
/* Remove the status on the user */
ChanUserContainer *cc = u->FindChannel(this);
@@ -592,12 +594,12 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode,
;
else if (ts > this->creation_time)
{
- Log(LOG_DEBUG) << "Dropping mode " << mode << " on " << this->name << ", " << ts << " > " << this->creation_time;
+ Anope::Logger.Debug("Dropping mode {0} on {1}, TS {2] > {3}", mode, this->GetName(), ts, this->creation_time);
return;
}
else if (ts < this->creation_time)
{
- Log(LOG_DEBUG) << "Changing TS of " << this->name << " from " << this->creation_time << " to " << ts;
+ Anope::Logger.Debug("Changing TS of {0} from {1} to {2}", this->GetName(), this->creation_time, ts);
this->creation_time = ts;
this->Reset();
}
@@ -635,7 +637,7 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode,
cm = ModeManager::FindChannelModeByChar(m[i]);
if (!cm)
{
- Log(LOG_DEBUG) << "Channel::SetModeInternal: Unknown mode char " << m[i];
+ Anope::Logger.Debug("Channel::SetModeInternal: Unknown mode char {0}", m[i]);
continue;
}
modestring += cm->mchar;
@@ -678,7 +680,9 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode,
this->RemoveModeInternal(source, cm, token, enforce_mlock);
}
else
- Log() << "warning: Channel::SetModesInternal() received more modes requiring params than params, modes: " << mode;
+ {
+ Anope::Logger.Log("warning: Channel::SetModesInternal() received more modes requiring params than params, modes: {0}", mode);
+ }
}
if (!this_reference)
@@ -696,9 +700,9 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode,
}
if (setter)
- Log(setter, this, "mode") << modestring << paramstring;
+ logger.Category("mode").Log("{0} {1}", modestring, paramstring);
else
- Log(LOG_DEBUG) << source.GetName() << " is setting " << this->name << " to " << modestring << paramstring;
+ logger.Debug("{0} is setting {1] to {2}{3}", source.GetName(), this->GetName(), modestring, paramstring);
if (enforce_mlock)
this->CheckModes();
@@ -724,23 +728,24 @@ bool Channel::KickInternal(const MessageSource &source, const Anope::string &nic
{
User *sender = source.GetUser();
User *target = User::Find(nick);
+
if (!target)
{
- Log(LOG_DEBUG) << "Channel::KickInternal got a nonexistent user " << nick << " on " << this->name << ": " << reason;
+ Anope::Logger.Debug("Channel::KickInternal got a nonexistent user {0} on {1}: {2}", nick, this->GetName(), reason);
return false;
}
if (sender)
- Log(sender, this, "kick") << "kicked " << target->nick << " (" << reason << ")";
+ logger.User(sender).Category("kick").Log(_("{0} kicked {1} from {2} ({3})"), sender->GetMask(), target->GetMask(), this->GetName(), reason);
else
- Log(target, this, "kick") << "was kicked by " << source.GetName() << " (" << reason << ")";
+ logger.Category("kick").Log(_("{0} kicked {1} from {2} ({3})"), source.GetName(), target->GetMask(), this->GetName(), reason);
Anope::string chname = this->name;
ChanUserContainer *cu = target->FindChannel(this);
if (cu == NULL)
{
- Log(LOG_DEBUG) << "Channel::KickInternal got kick for user " << target->nick << " from " << source.GetSource() << " who isn't on channel " << this->name;
+ Anope::Logger.Debug("Kick for user {0} who is not in channel {1}", target->GetMask(), this->GetName());
return false;
}
@@ -778,7 +783,7 @@ void Channel::ChangeTopicInternal(User *u, const Anope::string &user, const Anop
this->topic_ts = ts;
this->topic_time = Anope::CurTime;
- Log(LOG_DEBUG) << "Topic of " << this->name << " changed by " << this->topic_setter << " to " << newtopic;
+ Anope::Logger.Debug("Topic of {0} changed by {1} to {2}", this->GetName(), this->topic_setter, newtopic);
EventManager::Get()->Dispatch(&Event::TopicUpdated::OnTopicUpdated, u, this, user, this->topic);
}
@@ -805,7 +810,7 @@ void Channel::SetCorrectModes(User *user, bool give_modes)
if (!this->ci)
return;
- Log(LOG_DEBUG) << "Setting correct user modes for " << user->nick << " on " << this->name << " (" << (give_modes ? "" : "not ") << "giving modes)";
+ Anope::Logger.Debug("Setting correct user modes for {0} on {1} ({2}giving modes)", user->nick, this->name, give_modes ? "" : "not ");
ChanServ::AccessGroup u_access = ci->AccessFor(user);
@@ -892,7 +897,7 @@ bool Channel::CheckKick(User *user)
if (reason.empty())
reason = Language::Translate(user->Account(), _("You are not permitted to be on this channel."));
- Log(LOG_DEBUG) << "Autokicking " << user->nick << " (" << mask << ") from " << this->name;
+ Anope::Logger.Debug("Autokicking {0} ({1}) from {2}", user->nick, mask, this->name);
this->SetMode(NULL, "BAN", mask);
this->Kick(NULL, user, reason);
diff --git a/src/command.cpp b/src/command.cpp
index 7a87b07f3..9095c0526 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -31,8 +31,12 @@
#include "modules/botserv.h"
#include "modules/chanserv.h"
-CommandSource::CommandSource(const Anope::string &n, User *user, NickServ::Account *core, CommandReply *r, ServiceBot *bi) : nick(n), u(user), nc(core), reply(r),
- c(NULL), service(bi)
+CommandSource::CommandSource(const Anope::string &n, User *user, NickServ::Account *core, CommandReply *r, ServiceBot *bi)
+ : nick(n)
+ , u(user)
+ , nc(core)
+ , reply(r)
+ , service(bi)
{
}
@@ -51,6 +55,24 @@ NickServ::Account *CommandSource::GetAccount()
return this->nc;
}
+Anope::string CommandSource::GetSource()
+{
+ if (u)
+ if (nc)
+ return this->u->GetMask() + " (" + this->nc->GetDisplay() + ")";
+ else
+ return this->u->GetMask();
+ else if (nc)
+ return nc->GetDisplay();
+ else
+ return this->nick;
+}
+
+const Anope::string &CommandSource::GetCommand() const
+{
+ return this->command;
+}
+
ChanServ::AccessGroup CommandSource::AccessFor(ChanServ::Channel *ci)
{
if (this->u)
@@ -120,9 +142,12 @@ void CommandSource::Reply(const Anope::string &message)
this->reply->SendMessage(*this->service, tok);
}
-Command::Command(Module *o, const Anope::string &sname, size_t minparams, size_t maxparams) : Service(o, NAME, sname), max_params(maxparams), min_params(minparams), module(o)
+Command::Command(Module *o, const Anope::string &sname, size_t minparams, size_t maxparams) : Service(o, NAME, sname)
+ , max_params(maxparams)
+ , min_params(minparams)
+ , module(o)
+ , logger(this)
{
- allow_unregistered = require_user = false;
}
Command::~Command()
@@ -234,7 +259,7 @@ void Command::Run(CommandSource &source, const Anope::string &message)
source.Reply(_("Unknown command \002{0}\002. \"{1}{2} HELP\" for help."), message, Config->StrictPrivmsg, source.service->nick);
else
source.Reply(_("Unknown command \002{0}\002."), message);
- Log(source.service) << "Command " << it->first << " exists on me, but its service " << info.name << " was not found!";
+ source.service->logger.Log("Command {0} exists on me, but its service {1} was not found!", it->first, info.name);
return;
}
@@ -260,7 +285,7 @@ void Command::Run(CommandSource &source, const Anope::string &cmdname, const Com
{
source.Reply(_("Password authentication required for that command."));
if (source.GetUser())
- Log(LOG_NORMAL, "access_denied_unreg", source.service) << "Access denied for unregistered user " << source.GetUser()->GetMask() << " with command " << cmdname;
+ Anope::Logger.User(source.service).Category("access_denied_unreg").Log(_("Access denied for unregistered user {0} with command {1}"), source.GetUser()->GetMask(), cmdname);
return;
}
@@ -285,7 +310,7 @@ void Command::Run(CommandSource &source, const Anope::string &cmdname, const Com
else
source.Reply(_("Access denied. You do not have access to command \002{0}\002."), info.permission);
if (source.GetUser())
- Log(LOG_NORMAL, "access_denied", source.service) << "Access denied for user " << source.GetUser()->GetMask() << " with command " << cmdname;
+ Anope::Logger.User(source.service).Category("access_denied").Log(_("Access denied for user {0} with command {1}"), source.GetUser()->GetMask(), cmdname);
return;
}
diff --git a/src/config.cpp b/src/config.cpp
index e34177e8f..fbac466d9 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -307,7 +307,7 @@ Conf::Conf() : Block("")
if (ot2->GetName().equals_ci(str))
{
- Log() << "Inheriting commands and privs from " << ot2->GetName() << " to " << ot->GetName();
+ Anope::Logger.Log(_("Inheriting commands and privs from {0} to {1}"), ot2->GetName(), ot->GetName());
ot->Inherits(ot2);
break;
}
@@ -528,7 +528,7 @@ Conf::Conf() : Block("")
/* Check the user keys */
if (!options->Get<unsigned>("seed"))
- Log() << "Configuration option options:seed should be set. It's for YOUR safety! Remember that!";
+ Anope::Logger.Log(_("Configuration option options:seed should be set. It's for YOUR safety! Remember that!"));
/* check regexengine */
const Anope::string &regex_engine = options->Get<Anope::string>("regexengine");
@@ -725,7 +725,7 @@ void Conf::LoadOpers()
ot = this->MyOperTypes[j];
if (ot == NULL)
{
- Log() << "Oper block for " << nname << " has invalid oper type " << type;
+ Anope::Logger.Log(_("Oper block for {0} has invalid oper type {1}"), nname, type);
continue;
}
@@ -741,7 +741,7 @@ void Conf::LoadOpers()
o->SetHost(host);
o->SetVhost(vhost);
- Log(LOG_DEBUG) << "Creating oper " << nname << " of type " << ot->GetName();
+ Anope::Logger.Debug(_("Creating oper {0} of type {1}"), nname, ot->GetName());
}
/* Apply new opers */
@@ -752,7 +752,7 @@ void Conf::LoadOpers()
continue;
na->GetAccount()->SetOper(o);
- Log() << "Tied oper " << na->GetAccount()->GetDisplay() << " to type " << o->GetType()->GetName();
+ Anope::Logger.Log(_("Tied oper {0} to type {1}"), na->GetAccount()->GetDisplay(), o->GetType()->GetName());
}
}
@@ -896,7 +896,7 @@ void Conf::LoadConf(File &file)
int linenumber = 0;
bool in_word = false, in_quote = false, in_comment = false;
- Log(LOG_DEBUG) << "Start to read conf " << file.GetName();
+ Anope::Logger.Debug("Start to read conf {0}", file.GetName());
// Start reading characters...
while (!file.End())
{
@@ -907,7 +907,7 @@ void Conf::LoadConf(File &file)
if (line.empty() && in_quote)
wordbuffer += "\n";
- for (unsigned c = 0, len = line.length(); c < len; ++c)
+ for (unsigned int c = 0, len = line.length(); c < len; ++c)
{
char ch = line[c];
if (in_quote)
@@ -1056,7 +1056,7 @@ void Conf::LoadConf(File &file)
Block *b = block_stack.top();
if (b)
- Log(LOG_DEBUG) << "ln " << linenumber << " EOL: s='" << b->name << "' '" << itemname << "' set to '" << wordbuffer << "'";
+ Anope::Logger.Debug("ln {0} EOL: s='{1}' '{2}' set to '{3}'", linenumber, b->name, itemname, wordbuffer);
/* Check defines */
for (int i = 0; i < this->CountBlock("define"); ++i)
diff --git a/src/extensible.cpp b/src/extensible.cpp
index dc468fae7..524d74be3 100644
--- a/src/extensible.cpp
+++ b/src/extensible.cpp
@@ -39,7 +39,7 @@ bool Extensible::HasExtOK(const Anope::string &name)
if (ref)
return ref->HasExt(this);
- Log(LOG_DEBUG) << "HasExt for nonexistent type " << name << " on " << static_cast<const void *>(this);
+ Anope::Logger.Debug("HasExt for nonexistent type {0} on {1}", name, static_cast<const void *>(this));
return false;
}
diff --git a/src/init.cpp b/src/init.cpp
index 92cc70e9a..2922edaf1 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -144,18 +144,18 @@ void Anope::HandleSignal()
}
catch (const ConfigException &ex)
{
- Log() << "Error reloading configuration file: " << ex.GetReason();
+ Anope::Logger.Log("Error reloading configuration file: {0}", ex.GetReason());
}
break;
}
case SIGTERM:
case SIGINT:
#ifndef _WIN32
- Log() << "Received " << strsignal(Signal) << " signal (" << Signal << "), exiting.";
+ Anope::Logger.Log(_("Received {0} signal ({1}), exiting"), strsignal(Signal), Signal);
Anope::QuitReason = Anope::string("Services terminating via signal ") + strsignal(Signal) + " (" + stringify(Signal) + ")";
#else
- Log() << "Received signal " << Signal << ", exiting.";
- Anope::QuitReason = Anope::string("Services terminating via signal ") + stringify(Signal);
+ Anope::Logger.Log(_("Received signal {0}, exiting"), Signal);
+ Anope::QuitReason = "Services terminating via signal " + stringify(Signal);
#endif
Anope::Quitting = true;
break;
@@ -248,7 +248,7 @@ static void setuidgid()
errno = 0;
struct passwd *u = getpwnam(options->Get<Anope::string>("user").c_str());
if (u == NULL)
- Log() << "Unable to setuid to " << options->Get<Anope::string>("user") << ": " << Anope::LastError();
+ Anope::Logger.Log(_("Unable to setuid to {0}: {1}"), options->Get<Anope::string>("user"), Anope::LastError());
else
uid = u->pw_uid;
}
@@ -257,7 +257,7 @@ static void setuidgid()
errno = 0;
struct group *g = getgrnam(options->Get<Anope::string>("group").c_str());
if (g == NULL)
- Log() << "Unable to setgid to " << options->Get<Anope::string>("group") << ": " << Anope::LastError();
+ Anope::Logger.Log(_("Unable to setgid to {0}: {1}"), options->Get<Anope::string>("group"), Anope::LastError());
else
gid = g->gr_gid;
}
@@ -277,16 +277,16 @@ static void setuidgid()
if (static_cast<int>(gid) != -1)
{
if (setgid(gid) == -1)
- Log() << "Unable to setgid to " << options->Get<Anope::string>("group") << ": " << Anope::LastError();
+ Anope::Logger.Log(_("Unable to setgid to {0}: {1}"), options->Get<Anope::string>("group"), Anope::LastError());
else
- Log() << "Successfully set group to " << options->Get<Anope::string>("group");
+ Anope::Logger.Log(_("Successfully set group to {0"), options->Get<Anope::string>("group"));
}
if (static_cast<int>(uid) != -1)
{
if (setuid(uid) == -1)
- Log() << "Unable to setuid to " << options->Get<Anope::string>("user") << ": " << Anope::LastError();
+ Anope::Logger.Log(_("Unable to setuid to {0}: {1}"), options->Get<Anope::string>("user"), Anope::LastError());
else
- Log() << "Successfully set user to " << options->Get<Anope::string>("user");
+ Anope::Logger.Log(_("Successfully set user to {0}"), options->Get<Anope::string>("user"));
}
#endif
}
@@ -303,33 +303,33 @@ void Anope::Init(int ac, char **av)
if (GetCommandLineArgument("version", 'v'))
{
- Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- Built: " << Anope::VersionBuildTime() << " -- Flags: " << Anope::VersionFlags();
+ Anope::Logger.Terminal(_("Anope-{0} -- Built: {1} -- Flags: {2}"), Anope::Version(), Anope::VersionBuildTime(), Anope::VersionFlags());
exit(EXIT_SUCCESS);
}
if (GetCommandLineArgument("help", 'h'))
{
- Log(LOG_TERMINAL) << "Anope-" << Anope::Version();
- Log(LOG_TERMINAL) << "Anope IRC Services (https://anope.org)";
- Log(LOG_TERMINAL) << "Usage ./" << Anope::ServicesBin << " [options] ...";
- Log(LOG_TERMINAL) << "-c, --config=filename.conf";
- Log(LOG_TERMINAL) << " --confdir=conf file direcory";
- Log(LOG_TERMINAL) << " --dbdir=database directory";
- Log(LOG_TERMINAL) << "-d, --debug[=level]";
- Log(LOG_TERMINAL) << "-h, --help";
- Log(LOG_TERMINAL) << " --localedir=locale directory";
- Log(LOG_TERMINAL) << " --logdir=logs directory";
- Log(LOG_TERMINAL) << " --modulesdir=modules directory";
- Log(LOG_TERMINAL) << "-e, --noexpire";
- Log(LOG_TERMINAL) << "-n, --nofork";
- Log(LOG_TERMINAL) << " --nothird";
- Log(LOG_TERMINAL) << " --protocoldebug";
- Log(LOG_TERMINAL) << "-r, --readonly";
- Log(LOG_TERMINAL) << "-s, --support";
- Log(LOG_TERMINAL) << "-v, --version";
- Log(LOG_TERMINAL) << "";
- Log(LOG_TERMINAL) << "Further support is available from https://anope.org";
- Log(LOG_TERMINAL) << "Or visit us on IRC at irc.anope.org #anope";
+ Anope::Logger.Terminal(_("Anope-{0}"), Anope::Version());
+ Anope::Logger.Terminal(_("Anope IRC Services (https://anope.org)"));
+ Anope::Logger.Terminal(_("Usage ./{0} [options] ..."), Anope::ServicesBin);
+ Anope::Logger.Terminal(_("-c, --config=filename.conf"));
+ Anope::Logger.Terminal(_(" --confdir=conf file direcory"));
+ Anope::Logger.Terminal(_(" --dbdir=database directory"));
+ Anope::Logger.Terminal(_("-d, --debug[=level]"));
+ Anope::Logger.Terminal(_("-h, --help"));
+ Anope::Logger.Terminal(_(" --localedir=locale directory"));
+ Anope::Logger.Terminal(_(" --logdir=logs directory"));
+ Anope::Logger.Terminal(_(" --modulesdir=modules directory"));
+ Anope::Logger.Terminal(_("-e, --noexpire"));
+ Anope::Logger.Terminal(_("-n, --nofork"));
+ Anope::Logger.Terminal(_(" --nothird"));
+ Anope::Logger.Terminal(_(" --protocoldebug"));
+ Anope::Logger.Terminal(_("-r, --readonly"));
+ Anope::Logger.Terminal(_("-s, --support"));
+ Anope::Logger.Terminal(_("-v, --version"));
+ Anope::Logger.Terminal("");
+ Anope::Logger.Terminal(_("Further support is available from https://anope.org"));
+ Anope::Logger.Terminal(_("Or visit us on IRC at irc.anope.org #anope"));
exit(EXIT_SUCCESS);
}
@@ -417,7 +417,7 @@ void Anope::Init(int ac, char **av)
throw CoreException("Unable to chdir to " + Anope::ServicesDir + ": " + Anope::LastError());
}
- Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- Built: " << Anope::VersionBuildTime() << " -- Flags: " << Anope::VersionFlags();
+ Anope::Logger.Terminal("Anope-{0} -- Built: {1} -- Flags: {2}", Anope::Version(), Anope::VersionBuildTime(), Anope::VersionFlags());
#ifdef _WIN32
if (!SupportedWindowsVersion())
@@ -439,9 +439,9 @@ void Anope::Init(int ac, char **av)
#endif
#ifdef _WIN32
- Log(LOG_TERMINAL) << "Using configuration file " << Anope::ConfigDir << "\\" << ServicesConf.GetName();
+ Anope::Logger.Terminal("Using configuration file {0}\\{1}", Anope::ConfigDir, ServicesConf.GetName());
#else
- Log(LOG_TERMINAL) << "Using configuration file " << Anope::ConfigDir << "/" << ServicesConf.GetName();
+ Anope::Logger.Terminal("Using configuration file {0}/{1}", Anope::ConfigDir, ServicesConf.GetName());
/* Fork to background */
if (!Anope::NoFork)
@@ -471,7 +471,7 @@ void Anope::Init(int ac, char **av)
}
else if (i == -1)
{
- Log() << "Error, unable to fork: " << Anope::LastError();
+ Anope::Logger.Terminal("Error, unable to fork: {0}", Anope::LastError());
Anope::NoFork = true;
}
@@ -499,11 +499,11 @@ void Anope::Init(int ac, char **av)
}
catch (const ConfigException &ex)
{
- Log(LOG_TERMINAL) << ex.GetReason();
- Log(LOG_TERMINAL) << "*** Support resources: Read through the anope.conf self-contained";
- Log(LOG_TERMINAL) << "*** documentation. Read the documentation files found in the 'docs'";
- Log(LOG_TERMINAL) << "*** folder. Visit our portal located at https://anope.org/. Join";
- Log(LOG_TERMINAL) << "*** our support channel on irc.anope.org #anope.";
+ Anope::Logger.Terminal(ex.GetReason());
+ Anope::Logger.Terminal("*** Support resources: Read through the anope.conf self-contained");
+ Anope::Logger.Terminal("*** documentation. Read the documentation files found in the 'docs'");
+ Anope::Logger.Terminal("*** folder. Visit our portal located at https://anope.org/. Join");
+ Anope::Logger.Terminal("*** our support channel on irc.anope.org #anope.");
throw CoreException("Configuration file failed to validate");
}
@@ -522,7 +522,12 @@ void Anope::Init(int ac, char **av)
}
/* Announce ourselves to the logfile. */
- Log() << "Anope " << Anope::Version() << " starting up" << (Anope::Debug || Anope::ReadOnly ? " (options:" : "") << (Anope::Debug ? " debug" : "") << (Anope::ReadOnly ? " readonly" : "") << (Anope::Debug || Anope::ReadOnly ? ")" : "");
+ if (Anope::Debug || Anope::ReadOnly)
+ Anope::Logger.Log("Anope {0} starting up ({1})",
+ Anope::Version(),
+ Anope::Format("options:{0}{1}", Anope::Debug ? " debug" : "", Anope::ReadOnly ? " readonly" : ""));
+ else
+ Anope::Logger.Log("Anope {0} starting up", Anope::Version());
InitSignals();
@@ -536,7 +541,7 @@ void Anope::Init(int ac, char **av)
ModeManager::Apply(nullptr);
/* load modules */
- Log() << "Loading modules...";
+ Anope::Logger.Log("Loading modules...");
for (int i = 0; i < Config->CountBlock("module"); ++i)
ModuleManager::LoadModule(Config->GetBlock("module", i)->Get<Anope::string>("name"), NULL);
@@ -556,7 +561,7 @@ void Anope::Init(int ac, char **av)
/* Write our PID to the PID file. */
write_pidfile();
- Log() << "Using IRCd protocol " << protocol->name;
+ Anope::Logger.Log("Using IRCd protocol {0}", protocol->GetName());
/* Auto assign sid if applicable */
if (IRCD->RequiresID)
@@ -576,10 +581,9 @@ void Anope::Init(int ac, char **av)
}
/* Load up databases */
- Log() << "Loading databases...";
- EventReturn MOD_RESULT = EventManager::Get()->Dispatch(&Event::LoadDatabase::OnLoadDatabase);;
- static_cast<void>(MOD_RESULT);
- Log() << "Databases loaded";
+ Anope::Logger.Log("Loading databases...");
+ EventManager::Get()->Dispatch(&Event::LoadDatabase::OnLoadDatabase);;
+ Anope::Logger.Log("Databases loaded");
for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
it->second->Sync();
diff --git a/src/language.cpp b/src/language.cpp
index 8c3e6221a..238449aaa 100644
--- a/src/language.cpp
+++ b/src/language.cpp
@@ -34,14 +34,14 @@ std::vector<Anope::string> Language::Domains;
void Language::InitLanguages()
{
#if GETTEXT_FOUND
- Log(LOG_DEBUG) << "Initializing Languages...";
+ Anope::Logger.Debug("Initializing Languages...");
Languages.clear();
if (!bindtextdomain("anope", Anope::LocaleDir.c_str()))
- Log() << "Error calling bindtextdomain, " << Anope::LastError();
+ Anope::Logger.Log("Error calling bindtextdomain, {0}", Anope::LastError());
else
- Log(LOG_DEBUG) << "Successfully bound anope to " << Anope::LocaleDir;
+ Anope::Logger.Debug("Successfully bound anope to {0}", Anope::LocaleDir);
setlocale(LC_ALL, "");
@@ -52,15 +52,15 @@ void Language::InitLanguages()
const Anope::string &lang_name = Translate(language.c_str(), _("English"));
if (lang_name == "English")
{
- Log() << "Unable to use language " << language;
+ Anope::Logger.Log("Unable to use language {0}", language);
continue;
}
- Log(LOG_DEBUG) << "Found language " << language;
+ Anope::Logger.Debug("Found language {0}", language);
Languages.push_back(language);
}
#else
- Log() << "Unable to initialize languages, gettext is not installed";
+ Anope::Logger.Log("Unable to initialize languages, gettext is not installed");
#endif
}
@@ -109,7 +109,12 @@ const char *Language::Translate(const char *lang, const char *string)
return "";
if (!lang || !*lang)
+ {
+ if (Config == nullptr)
+ return string;
+
lang = Config->DefLanguage.c_str();
+ }
#ifdef __USE_GNU_GETTEXT
++_nl_msg_cat_cntr;
diff --