From aa4b3e256377030d291fc2d5f4db94985ce04395 Mon Sep 17 00:00:00 2001 From: DukePyrolator Date: Sun, 31 Jan 2010 06:15:29 +0000 Subject: replaced the alog() command with a new type-safe and stream-based Alog() git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2777 5417fbe8-f217-4b02-8779-1006273d7864 --- src/bots.cpp | 1 - src/channels.c | 121 ++++++++++++------------------ src/chanserv.c | 55 ++++++-------- src/commands.c | 12 +-- src/config.c | 37 +++++----- src/core/bs_kick.c | 66 ++++++----------- src/core/cs_access.c | 30 ++++---- src/core/cs_drop.c | 5 +- src/core/cs_forbid.c | 4 +- src/core/cs_register.c | 4 +- src/core/cs_set.c | 18 ++--- src/core/cs_suspend.c | 8 +- src/core/cs_topic.c | 2 +- src/core/cs_xop.c | 4 +- src/core/db_plain.cpp | 24 +++--- src/core/enc_md5.c | 3 +- src/core/enc_none.c | 3 +- src/core/enc_old.c | 3 +- src/core/enc_sha1.c | 3 +- src/core/enc_sha256.c | 3 +- src/core/hs_del.c | 2 +- src/core/hs_delall.c | 2 +- src/core/hs_set.c | 8 +- src/core/hs_setall.c | 8 +- src/core/ms_rsend.c | 3 +- src/core/ns_drop.c | 4 +- src/core/ns_forbid.c | 4 +- src/core/ns_getemail.c | 2 +- src/core/ns_getpass.c | 4 +- src/core/ns_ghost.c | 2 +- src/core/ns_group.c | 12 +-- src/core/ns_identify.c | 6 +- src/core/ns_logout.c | 2 +- src/core/ns_recover.c | 2 +- src/core/ns_register.c | 18 ++--- src/core/ns_release.c | 2 +- src/core/ns_resetpass.c | 7 +- src/core/ns_saset.c | 6 +- src/core/ns_sendpass.c | 2 +- src/core/ns_set.c | 6 +- src/core/ns_suspend.c | 8 +- src/core/os_defcon.c | 18 ++--- src/core/os_ignore.c | 3 +- src/core/os_modunload.c | 2 +- src/core/os_news.c | 9 +-- src/core/os_set.c | 22 +++--- src/core/ss_main.c | 4 +- src/encrypt.c | 4 +- src/init.c | 32 ++++---- src/language.c | 27 +++---- src/log.c | 72 +++++++++--------- src/main.c | 25 +++---- src/memory.c | 2 +- src/memoserv.c | 7 +- src/messages.c | 8 +- src/misc.c | 10 +-- src/modes.cpp | 31 +++----- src/modulemanager.cpp | 29 ++++---- src/modules.c | 51 +++++-------- src/modules/cs_appendtopic.c | 2 +- src/modules/cs_enforce.c | 9 +-- src/modules/hs_request.c | 11 ++- src/modules/ns_maxemail.c | 4 +- src/modules/ns_noop_convert.c | 11 ++- src/nickcore.cpp | 2 +- src/nickserv.c | 47 +++--------- src/operserv.c | 2 +- src/process.c | 32 ++++---- src/protocol/bahamut.c | 19 ++--- src/protocol/inspircd11.c | 58 ++++++--------- src/protocol/inspircd12.cpp | 60 +++++++-------- src/protocol/ratbox.c | 25 ++----- src/protocol/unreal32.c | 60 +++++++-------- src/regchannel.cpp | 3 +- src/send.c | 12 +-- src/servers.c | 75 +++++++------------ src/sessions.c | 35 +++------ src/slist.c | 4 +- src/sockutil.c | 62 ++++++---------- src/users.c | 168 +++++++++++++++--------------------------- 80 files changed, 629 insertions(+), 944 deletions(-) (limited to 'src') diff --git a/src/bots.cpp b/src/bots.cpp index d19386abc..93121ba16 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -45,7 +45,6 @@ BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std:: insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL. // If we're synchronised with the uplink already, call introduce_user() for this bot. - alog("serv_uplink is %p and status is %d", static_cast(serv_uplink), serv_uplink ? serv_uplink->sync == SSYNC_DONE : 0); if (serv_uplink && serv_uplink->sync == SSYNC_DONE) ircdproto->SendClientIntroduction(this->nick, this->user, this->host, this->real, ircd->pseudoclient_mode, this->uid); } diff --git a/src/channels.c b/src/channels.c index 7f2467f62..0a8677820 100644 --- a/src/channels.c +++ b/src/channels.c @@ -63,8 +63,7 @@ Channel::~Channel() FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this)); - if (debug) - alog("debug: Deleting channel %s", this->name.c_str()); + Alog(LOG_DEBUG) << "Deleting channel " << this->name; for (bd = this->bd; bd; bd = next) { @@ -126,8 +125,7 @@ void Channel::Sync() void Channel::JoinUser(User *user) { - if (debug) - alog("debug: %s joins %s", user->nick.c_str(), this->name.c_str()); + Alog(LOG_DEBUG) << user->nick << " joins " << this->name; Flags *Status = new Flags; ChannelContainer *cc = new ChannelContainer(this); @@ -195,8 +193,7 @@ void Channel::DeleteUser(User *user) for (cit = this->users.begin(); (*cit)->user != user && cit != this->users.end(); ++cit); if (cit == this->users.end()) { - if (debug) - alog("debug: Channel::DeleteUser() tried to delete nonexistnat user %s from channel %s", user->nick.c_str(), this->name.c_str()); + Alog(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant user " << user->nick << " from channel " << this->name; return; } @@ -208,8 +205,7 @@ void Channel::DeleteUser(User *user) for (uit = user->chans.begin(); (*uit)->chan != this && uit != user->chans.end(); ++uit); if (uit == user->chans.end()) { - if (debug) - alog("debug: Channel::DeleteUser() tried to delete nonexistant channel %s from %s's channel list", this->name.c_str(), user->nick.c_str()); + Alog(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant channel " << this->name << " from " << user->nick << "'s channel list"; return; } @@ -311,7 +307,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string ¶m, bool En { if (param.empty()) { - alog("Channel::SetModeInternal() mode %c with no parameter for channel %s", cm->ModeChar, this->name.c_str()); + Alog() << "Channel::SetModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; return; } @@ -322,13 +318,11 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string ¶m, bool En User *u = finduser(param); if (!u) { - if (debug) - alog("debug: MODE %s +%c for nonexistant user %s", this->name.c_str(), cm->ModeChar, param.c_str()); + Alog(LOG_DEBUG) << "MODE " << this->name << " +" << cm->ModeChar << " for nonexistant user " << param; return; } - if (debug) - alog("debug: Setting +%c on %s for %s", cm->ModeChar, this->name.c_str(), u->nick.c_str()); + Alog(LOG_DEBUG) << "Setting +" << cm->ModeChar << " on " << this->name << " for " << u->nick; /* Set the status on the user */ ChannelContainer *cc = u->FindChannel(this); @@ -346,7 +340,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string ¶m, bool En { if (param.empty()) { - alog("Channel::SetModeInternal() mode %c with no parameter for channel %s", cm->ModeChar, this->name.c_str()); + Alog() << "Channel::SetModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; return; } @@ -361,7 +355,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string ¶m, bool En { if (cm->Type != MODE_PARAM) { - alog("Channel::SetModeInternal() mode %c for %s with a paramater, but its not a param mode", cm->ModeChar, this->name.c_str()); + Alog() << "Channel::SetModeInternal() mode " << cm->ModeChar << " for " << this->name << " with a paramater, but its not a param mode"; return; } @@ -447,7 +441,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string ¶m, bool { if (param.empty()) { - alog("Channel::RemoveModeInternal() mode %c with no parameter for channel %s", cm->ModeChar, this->name.c_str()); + Alog() << "Channel::RemoveModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; return; } @@ -458,12 +452,11 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string ¶m, bool User *u = finduser(param); if (!u) { - alog("Channel::RemoveModeInternal() MODE %s -%c for nonexistant user %s", this->name.c_str(), cm->ModeChar, param.c_str()); + Alog() << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->ModeChar << " for nonexistant user " << param; return; } - if (debug) - alog("debug: Setting -%c on %s for %s", cm->ModeChar, this->name.c_str(), u->nick.c_str()); + Alog(LOG_DEBUG) << "Setting -" << cm->ModeChar << " on " << this->name << " for " << u->nick; /* Remove the status on the user */ ChannelContainer *cc = u->FindChannel(this); @@ -479,7 +472,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string ¶m, bool { if (param.empty()) { - alog("Channel::RemoveModeInternal() mode %c with no parameter for channel %s", cm->ModeChar, this->name.c_str()); + Alog() << "Channel::RemoveModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; return; } @@ -895,13 +888,13 @@ void ChanSetInternalModes(Channel *c, int ac, const char **av) } else { - alog("warning: ChanSetInternalModes() recieved more modes requiring params than params, modes: %s, ac: %d, j: %d", merge_args(ac, av), ac, j); + Alog() << "warning: ChanSetInternalModes() recieved more modes requiring params than params, modes: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j; } } if (j + k + 1 < ac) { - alog("warning: ChanSetInternalModes() recieved more params than modes requiring them, modes: %s, ac: %d, j: %d k: %d", merge_args(ac, av), ac, j, k); + Alog() << "warning: ChanSetInternalModes() recieved more params than modes requiring them, modes: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j << " k: " << k; } } @@ -925,21 +918,19 @@ void Channel::KickInternal(const std::string &source, const std::string &nick, c User *user = finduser(nick); if (!user) { - if (debug) - alog("debug: Channel::KickInternal got a nonexistent user %s on %s: %s", nick.c_str(), this->name.c_str(), reason.c_str()); + Alog(LOG_DEBUG) << "Channel::KickInternal got a nonexistent user " << nick << " on " << this->name << ": " << reason; return; } - if (debug) - alog("debug: Channel::KickInternal kicking %s from %s", user->nick.c_str(), this->name.c_str()); + Alog(LOG_DEBUG) << "Channel::KickInternal kicking " << user->nick << " from " << this->name; if (user->FindChannel(this)) { FOREACH_MOD(I_OnUserKicked, OnUserKicked(this, user, source, reason)); this->DeleteUser(user); } - else if (debug) - alog("debug: Channel::KickInternal got kick for user %s who isn't on channel %s ?", user->nick.c_str(), this->name.c_str()); + else + Alog(LOG_DEBUG) << "Channel::KickInternal got kick for user " << user->nick << " who isn't on channel " << this->name << " ?"; } /** Kick a user from the channel @@ -1037,26 +1028,22 @@ Channel *findchan(const char *chan) { Channel *c; - if (!chan || !*chan) { - if (debug) { - alog("debug: findchan() called with NULL values"); - } + if (!chan || !*chan) + { + Alog(LOG_DEBUG) << "findchan() called with NULL values"; return NULL; } - if (debug >= 3) - alog("debug: findchan(%p)", chan); c = chanlist[HASH(chan)]; - while (c) { - if (stricmp(c->name.c_str(), chan) == 0) { - if (debug >= 3) - alog("debug: findchan(%s) -> %p", chan, static_cast(c)); + while (c) + { + if (stricmp(c->name.c_str(), chan) == 0) + { + Alog(LOG_DEBUG_3) << "findchan(" << chan << ") -> " << static_cast(c); return c; } c = c->next; } - if (debug >= 3) - alog("debug: findchan(%s) -> %p", chan, static_cast(c)); return NULL; } @@ -1074,9 +1061,7 @@ Channel *firstchan() next_index = 0; while (next_index < 1024 && current == NULL) current = chanlist[next_index++]; - if (debug >= 3) - alog("debug: firstchan() returning %s", - current ? current->name.c_str() : "NULL (end of list)"); + Alog(LOG_DEBUG_3) << "firstchan() returning " << (current ? current->name : "NULL (end of list)"); return current; } @@ -1088,9 +1073,7 @@ Channel *nextchan() while (next_index < 1024 && current == NULL) current = chanlist[next_index++]; } - if (debug >= 3) - alog("debug: nextchan() returning %s", - current ? current->name.c_str() : "NULL (end of list)"); + Alog(LOG_DEBUG_3) << "nextchan() returning " << (current ? current->name : "NULL (end of list)"); return current; } @@ -1176,11 +1159,9 @@ void do_join(const char *source, int ac, const char **av) time_t ctime = time(NULL); user = finduser(source); - if (!user) { - if (debug) { - alog("debug: JOIN from nonexistent user %s: %s", source, - merge_args(ac, av)); - } + if (!user) + { + Alog(LOG_DEBUG) << "JOIN from nonexistent user " << source << ": " << merge_args(ac, av); return; } @@ -1219,8 +1200,7 @@ void do_join(const char *source, int ac, const char **av) /* Their time is older, we lose */ if (chan->creation_time > ts) { - if (debug) - alog("debug: recieved a new TS for JOIN: %ld", ts); + Alog(LOG_DEBUG) << "recieved a new TS for JOIN: " << ts; if (chan->ci) { @@ -1267,8 +1247,7 @@ void do_kick(const std::string &source, int ac, const char **av) Channel *c = findchan(av[0]); if (!c) { - if (debug) - alog("Recieved kick for nonexistant channel %s", av[0]); + Alog(LOG_DEBUG) << "Recieved kick for nonexistant channel " << av[0]; return; } @@ -1292,8 +1271,7 @@ void do_part(const char *source, int ac, const char **av) User *user = finduser(source); if (!user) { - if (debug) - alog("debug: PART from nonexistent user %s: %s", source, merge_args(ac, av)); + Alog(LOG_DEBUG) << "PART from nonexistent user " << source << ": " << merge_args(ac, av); return; } @@ -1305,12 +1283,10 @@ void do_part(const char *source, int ac, const char **av) if (!c) { - if (debug) - alog("debug: Recieved PART from %s for nonexistant channel %s", user->nick.c_str(), buf.c_str()); + Alog(LOG_DEBUG) << "Recieved PART from " << user->nick << " for nonexistant channel " << buf; } - if (debug) - alog("debug: %s leaves %s", source, buf.c_str()); + Alog(LOG_DEBUG) << source << " leaves " << buf; if (user->FindChannel(c)) { @@ -1319,8 +1295,8 @@ void do_part(const char *source, int ac, const char **av) c->DeleteUser(user); FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(ChannelName.c_str()), ChannelName, av[1] ? av[1] : "")); } - else if (debug) - alog("debug: Recieved PART from %s for %s, but %s isn't in %s ?", user->nick.c_str(), c->name.c_str(), user->nick.c_str(), c->name.c_str()); + else + Alog(LOG_DEBUG) << "Recieved PART from " << user->nick << " for " << c->name << ", but " << user->nick << " isn't in " << c->name << "?"; } } @@ -1355,7 +1331,7 @@ void do_cmode(const char *source, int ac, const char **av) av++; } else - alog("TSMODE enabled but MODE has no valid TS"); + Alog() << "TSMODE enabled but MODE has no valid TS"; } } @@ -1376,7 +1352,7 @@ void do_cmode(const char *source, int ac, const char **av) { ci = cs_findchan(av[0]); if (!ci || ci->HasFlag(CI_FORBIDDEN)) - alog("debug: MODE %s for nonexistant channel %s", merge_args(ac - 1, av + 1), av[0]); + Alog(LOG_DEBUG) << "MODE " << merge_args(ac - 1, av + 1) << " for nonexistant channel " << av[0]; } return; } @@ -1410,20 +1386,16 @@ void do_topic(const char *source, int ac, const char **av) if (ircd->sjb64) { ts = base64dects(av[2]); - if (debug) { - alog("debug: encoded TOPIC TS %s converted to %d", av[2], ts); - } + Alog(LOG_DEBUG) << "encoded TOPIC TS " << av[2] << " converted to " << ts; } else { ts = strtoul(av[2], NULL, 10); } topic_time = ts; - if (!c) { - if (debug) { - alog("debug: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } + if (!c) + { + Alog(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; return; } @@ -1500,8 +1472,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes) if ((ci->HasFlag(CI_FORBIDDEN)) || (*(c->name.c_str()) == '+')) return; - if (debug) - alog("debug: Setting correct user modes for %s on %s (%sgiving modes)", user->nick.c_str(), c->name.c_str(), (give_modes ? "" : "not ")); + Alog(LOG_DEBUG) << "Setting correct user modes for " << user->nick << " on " << c->name << " (" << (give_modes ? "" : "not ") << "giving modes)"; if (give_modes && !get_ignore(user->nick.c_str()) && (!user->nc || !user->nc->HasFlag(NI_AUTOOP))) { diff --git a/src/chanserv.c b/src/chanserv.c index 56a94839c..deb0f139c 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -334,8 +334,7 @@ void check_modes(Channel *c) if (!c) { - if (debug) - alog("debug: check_modes called with NULL values"); + Alog(LOG_DEBUG) << "check_modes called with NULL values"; return; } @@ -346,7 +345,7 @@ void check_modes(Channel *c) if (c->server_modecount >= 3 && c->chanserv_modecount >= 3) { ircdproto->SendGlobops(NULL, "Warning: unable to set modes on channel %s. Are your servers' U:lines configured correctly?", c->name.c_str()); - alog("%s: Bouncy modes on channel %s", Config.s_ChanServ, c->name.c_str()); + Alog() << Config.s_ChanServ << ": Bouncy modes on channel " << c->name; c->bouncy_modes = 1; return; } @@ -664,19 +663,18 @@ bool ChannelInfo::CheckKick(User *user) if (!akick->InUse || do_kick) continue; - if ((akick->HasFlag(AK_ISNICK) && akick->nc == nc) + if ((akick->HasFlag(AK_ISNICK) && akick->nc == nc) || (!akick->HasFlag(AK_ISNICK) && match_usermask(akick->mask.c_str(), user))) - { - if (debug >= 2) - alog("debug: %s matched akick %s", user->nick.c_str(), akick->HasFlag(AK_ISNICK) ? akick->nc->display : akick->mask.c_str()); + { + Alog(LOG_DEBUG_2) << user->nick << " matched akick " << (akick->HasFlag(AK_ISNICK) ? akick->nc->display : akick->mask); if (akick->HasFlag(AK_ISNICK)) get_idealban(this, user, mask, sizeof(mask)); else strlcpy(mask, akick->mask.c_str(), sizeof(mask)); reason = !akick->reason.empty() ? akick->reason.c_str() : Config.CSAutokickReason; do_kick = true; - } + } } @@ -690,9 +688,7 @@ bool ChannelInfo::CheckKick(User *user) if (!do_kick) return false; - if (debug) - alog("debug: channel: AutoKicking %s!%s@%s from %s", user->nick.c_str(), - user->GetIdent().c_str(), user->host, this->name.c_str()); + Alog(LOG_DEBUG) << "channel: Autokicking "<< user->GetMask() << " from " << this->name; /* If the channel doesnt have any users and if a bot isn't already in the channel, join it * NOTE: we use usercount == 1 here as there is one user, but they are about to be destroyed @@ -807,10 +803,9 @@ int check_topiclock(Channel * c, time_t topic_time) { ChannelInfo *ci; - if (!c) { - if (debug) { - alog("debug: check_topiclock called with NULL values"); - } + if (!c) + { + Alog(LOG_DEBUG) << "check_topiclock called with NULL values"; return 0; } @@ -886,8 +881,7 @@ void expire_chans() continue; char *chname = sstrdup(ci->name.c_str()); - alog("Expiring channel %s (founder: %s)", ci->name.c_str(), - (ci->founder ? ci->founder->display : "(none)")); + Alog() << "Expiring channel " << ci->name << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << " )"; delete ci; FOREACH_MOD(I_OnChanExpire, OnChanExpire(chname)); delete [] chname; @@ -914,17 +908,17 @@ void cs_remove_nick(const NickCore * nc) if (ci->successor) { NickCore *nc2 = ci->successor; if (!nc2->IsServicesOper() && Config.CSMaxReg && nc2->channelcount >= Config.CSMaxReg) { - alog("%s: Successor (%s) of %s owns too many channels, " "deleting channel", Config.s_ChanServ, nc2->display, ci->name.c_str()); + Alog() << Config.s_ChanServ << ": Successor (" << nc2->display << " ) of " << ci->name << " owns too many channels, deleting channel", delete ci; continue; } else { - alog("%s: Transferring foundership of %s from deleted " "nick %s to successor %s", Config.s_ChanServ, ci->name.c_str(), nc->display, nc2->display); + Alog() << Config.s_ChanServ << ": Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to successor " << nc2->display; ci->founder = nc2; ci->successor = NULL; nc2->channelcount++; } } else { - alog("%s: Deleting channel %s owned by deleted nick %s", Config.s_ChanServ, ci->name.c_str(), nc->display); + Alog() << Config.s_ChanServ << ": Deleting channel " << ci->name << "owned by deleted nick " << nc->display; if ((ModeManager::FindChannelModeByName(CMODE_REGISTERED))) { @@ -970,10 +964,9 @@ ChannelInfo *cs_findchan(const std::string &chan) { ChannelInfo *ci; - if (chan.empty()) { - if (debug) { - alog("debug: cs_findchan() called with NULL values"); - } + if (chan.empty()) + { + Alog(LOG_DEBUG) << "cs_findchan() called with NULL values"; return NULL; } @@ -1034,10 +1027,9 @@ void alpha_insert_chan(ChannelInfo * ci) { ChannelInfo *ptr, *prev; - if (!ci) { - if (debug) { - alog("debug: alpha_insert_chan called with NULL values"); - } + if (!ci) + { + Alog(LOG_DEBUG) << "alpha_insert_chan() called with NULL values"; return; } @@ -1062,10 +1054,9 @@ void reset_levels(ChannelInfo * ci) { int i; - if (!ci) { - if (debug) { - alog("debug: reset_levels called with NULL values"); - } + if (!ci) + { + Alog(LOG_DEBUG) << "reset_levels() called with NULL values"; return; } diff --git a/src/commands.c b/src/commands.c index 0c5ec0754..4e3b36e7a 100644 --- a/src/commands.c +++ b/src/commands.c @@ -71,7 +71,7 @@ void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[], if (!nick_identified(u)) { notice_lang(service, u, NICK_IDENTIFY_REQUIRED, Config.s_NickServ); - alog("Access denied for unregistered user %s with service %s and command %s", u->nick.c_str(), service.c_str(), cmd); + Alog() << "Access denied for unregistered user " << u->nick << " with service " << service << " and command " << cmd; return; } } @@ -121,15 +121,15 @@ void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[], if ((ci->HasFlag(CI_FORBIDDEN)) && (!c->HasFlag(CFLAG_ALLOW_FORBIDDEN))) { notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name.c_str()); - alog("Access denied for user %s with service %s and command %s because of FORBIDDEN channel %s", - u->nick.c_str(), service.c_str(), cmd, ci->name.c_str()); + Alog() << "Access denied for user " << u->nick << " with service " << service + << " and command " << cmd << " because of FORBIDDEN channel " << ci->name; return; } else if ((ci->HasFlag(CI_SUSPENDED)) && (!c->HasFlag(CFLAG_ALLOW_SUSPENDED))) { notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name.c_str()); - alog("Access denied for user %s with service %s and command %s because of SUSPENDED channel %s", - u->nick.c_str(), service.c_str(), cmd, ci->name.c_str()); + Alog() << "Access denied for user " << u->nick << " with service " << service + <<" and command " << cmd << " because of SUSPENDED channel " << ci->name; return; } } @@ -153,7 +153,7 @@ void mod_run_cmd(const std::string &service, User * u, CommandHash * cmdTable[], if (!u->nc->HasCommand(c->permission)) { notice_lang(service, u, ACCESS_DENIED); - alog("Access denied for user %s with service %s and command %s", u->nick.c_str(), service.c_str(), cmd); + Alog() << "Access denied for user " << u->nick << " with service " << service << " and command " << cmd; return; } diff --git a/src/config.c b/src/config.c index fba7baf1d..94fbd75af 100644 --- a/src/config.c +++ b/src/config.c @@ -312,13 +312,13 @@ bool ValidateNickLen(ServerConfig *, const char *, const char *, ValueItem &data int nicklen = data.GetInteger(); if (!nicklen) { - alog("You have not defined the directive. It is strongly"); - alog("adviced that you do configure this correctly in your services.conf"); + Alog() << "You have not defined the directive. It is strongly"; + Alog() << "adviced that you do configure this correctly in your services.conf"; data.Set(31); } else if (nicklen < 1) { - alog(" has an invalid value; setting to %d", 31); + Alog() << " has an invalid value; setting to 31"; data.Set(31); } return true; @@ -343,7 +343,7 @@ bool ValidateGlobalOnCycle(ServerConfig *, const char *tag, const char *value, V { if (data.GetValue().empty()) { - alog("<%s:%s> was undefined, disabling ", tag, value); + Alog() << "<" << tag << ":" << value << "> was undefined, disabling "; Config.GlobalOnCycle = false; } } @@ -352,7 +352,7 @@ bool ValidateGlobalOnCycle(ServerConfig *, const char *tag, const char *value, V void ServerConfig::ReportConfigError(const std::string &errormessage, bool bail) { - alog("There were errors in your configuration file: %s", errormessage.c_str()); + Alog() << "There were errors in your configuration file: " << errormessage; if (bail) { // TODO -- Need a way to stop loading in a safe way -- CyberBotX @@ -501,7 +501,7 @@ static bool DoneOpers(ServerConfig *, const char *, bool) OperType *ot = *tit; if (ot->GetName() == type) { - alog("Tied oper %s to type %s", na->nc->display, type.c_str()); + Alog() << "Tied oper " << na->nc->display << " to type " << type; na->nc->ot = ot; } } @@ -1020,12 +1020,11 @@ int ServerConfig::Read(bool bail) } return 0; } - if (debug) - alog("End config"); + Alog(LOG_DEBUG) << "End config"; for (int Index = 0; Once[Index]; ++Index) if (!CheckOnce(Once[Index])) return 0; - alog("Done reading configuration file."); + Alog() << "Done reading configuration file."; return 1; } @@ -1041,8 +1040,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char *filename, std::o errorstream << "File " << filename << " could not be opened." << std::endl; return false; } - if (debug) - alog("Start to read conf %s", filename); + Alog(LOG_DEBUG) << "Start to read conf " << filename; // Start reading characters... while (getline(conf, line)) { @@ -1146,8 +1144,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char *filename, std::o return false; } // this is the same as the below section for testing if itemname is non-empty after the loop, but done inside it to allow the above construct - if (debug) - alog("ln %d EOL: s='%s' '%s' set to '%s'", linenumber, section.c_str(), itemname.c_str(), wordbuffer.c_str()); + Alog(LOG_DEBUG) << "ln "<< linenumber << " EOL: s='" << section << "' '" << itemname << "' set to '" << wordbuffer << "'"; sectiondata.push_back(KeyVal(itemname, wordbuffer)); wordbuffer.clear(); itemname.clear(); @@ -1189,8 +1186,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char *filename, std::o errorstream << "Item without value: " << filename << ":" << linenumber << std::endl; return false; } - if (debug) - alog("ln %d EOL: s='%s' '%s' set to '%s'", linenumber, section.c_str(), itemname.c_str(), wordbuffer.c_str()); + Alog(LOG_DEBUG) << "ln " << linenumber << " EOL: s='" << section << "' '" << itemname << "' set to '" << wordbuffer << "'"; sectiondata.push_back(KeyVal(itemname, wordbuffer)); wordbuffer.clear(); itemname.clear(); @@ -1259,7 +1255,7 @@ bool ServerConfig::ConfValue(ConfigDataHash &target, const std::string &tag, con { if (!allow_linefeeds && j->second.find('\n') != std::string::npos) { - alog("Value of <%s:%s> contains a linefeed, and linefeeds in this value are not permitted -- stripped to spaces.", tag.c_str(), var.c_str()); + Alog(LOG_DEBUG) << "Value of <" << tag << ":" << var << "> contains a linefeed, and linefeeds in this value are not permitted -- stripped to spaces."; std::string::iterator n = j->second.begin(), nend = j->second.end(); for (; n != nend; ++n) if (*n == '\n') @@ -1478,9 +1474,10 @@ void error(int linenum, const char *message, ...) va_end(args); if (linenum) - alog("%s:%d: %s", SERVICES_CONF, linenum, buf); + Alog() << SERVICES_CONF << ":" << linenum << ": " << buf; else - alog("%s: %s", SERVICES_CONF, buf); + Alog() << SERVICES_CONF << ": " << buf; + if (!nofork && isatty(2)) { if (linenum) @@ -1567,7 +1564,7 @@ int read_config(int reload) else if (option == "secure") Config.NSDefFlags.SetFlag(NI_SECURE); else if (option == "private") Config.NSDefFlags.SetFlag(NI_PRIVATE); else if (option == "msg") { - if (!Config.UsePrivmsg) alog("msg in can only be used when UsePrivmsg is set"); + if (!Config.UsePrivmsg) Alog() << "msg in can only be used when UsePrivmsg is set"; else Config.NSDefFlags.SetFlag(NI_MSG); } else if (option == "hideemail") Config.NSDefFlags.SetFlag(NI_HIDE_EMAIL); @@ -1705,7 +1702,7 @@ int read_config(int reload) /* Check the user keys */ if ((Config.UserKey1 == Config.UserKey2) || (Config.UserKey1 == Config.UserKey3) || (Config.UserKey3 == Config.UserKey2)) - alog("Every UserKey must be different. It's for YOUR safety! Remember that!"); + Alog() << "Every UserKey must be different. It's for YOUR safety! Remember that!"; /** * Check all DEFCON dependiencies... diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c index 37cd742f5..be0815a29 100644 --- a/src/core/bs_kick.c +++ b/src/core/bs_kick.c @@ -46,15 +46,12 @@ class CommandBSKick : public Command if (value == "ON") { if (ttb) { errno = 0; - ci->ttb[TTB_BADWORDS] = - strtol(ttb, NULL, 10); + ci->ttb[TTB_BADWORDS] = strtol(ttb, NULL, 10); /* Only error if errno returns ERANGE or EINVAL or we are less then 0 - TSL */ - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_BADWORDS] < 0) { + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BADWORDS] < 0) + { /* leaving the debug behind since we might want to know what these are */ - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BADWORDS]); - } + Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_BADWORDS]; /* reset the value back to 0 - TSL */ ci->ttb[TTB_BADWORDS] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); @@ -78,11 +75,9 @@ class CommandBSKick : public Command if (ttb) { errno = 0; ci->ttb[TTB_BOLDS] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_BOLDS] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BOLDS]); - } + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_BOLDS] < 0) + { + Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_BOLDS]; ci->ttb[TTB_BOLDS] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; @@ -107,11 +102,9 @@ class CommandBSKick : public Command if (ttb) { errno = 0; ci->ttb[TTB_CAPS] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_CAPS] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_CAPS]); - } + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_CAPS] < 0) + { + Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_CAPS]; ci->ttb[TTB_CAPS] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; @@ -150,11 +143,9 @@ class CommandBSKick : public Command if (ttb) { errno = 0; ci->ttb[TTB_COLORS] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_COLORS] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_COLORS]); - } + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_COLORS] < 0) + { + Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_COLORS]; ci->ttb[TTB_COLORS] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; @@ -179,11 +170,8 @@ class CommandBSKick : public Command if (ttb) { errno = 0; ci->ttb[TTB_FLOOD] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_FLOOD] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_FLOOD]); - } + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_FLOOD] < 0) { + Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_FLOOD]; ci->ttb[TTB_FLOOD] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; @@ -224,11 +212,9 @@ class CommandBSKick : public Command if (ttb) { errno = 0; ci->ttb[TTB_REPEAT] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_REPEAT] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REPEAT]); - } + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REPEAT] < 0) + { + Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_REPEAT]; ci->ttb[TTB_REPEAT] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; @@ -260,11 +246,9 @@ class CommandBSKick : public Command errno = 0; ci->ttb[TTB_REVERSES] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_REVERSES] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REVERSES]); - } + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_REVERSES] < 0) + { + Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_REVERSES]; ci->ttb[TTB_REVERSES] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; @@ -287,11 +271,9 @@ class CommandBSKick : public Command errno = 0; ci->ttb[TTB_UNDERLINES] = strtol(ttb, NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_UNDERLINES] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_UNDERLINES]); - } + if (errno == ERANGE || errno == EINVAL || ci->ttb[TTB_UNDERLINES] < 0) + { + Alog(LOG_DEBUG) << "errno is " << errno << " ERANGE " << ERANGE << " EINVAL " << EINVAL << " ttb " << ci->ttb[TTB_UNDERLINES]; ci->ttb[TTB_UNDERLINES] = 0; notice_lang(Config.s_BotServ, u, BOT_KICK_BAD_TTB, ttb); return MOD_CONT; diff --git a/src/core/cs_access.c b/src/core/cs_access.c index ec62dec42..808141aa0 100644 --- a/src/core/cs_access.c +++ b/src/core/cs_access.c @@ -227,7 +227,8 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessChange, OnAccessChange(ci, u, na->nick, level)); - alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", Config.s_ChanServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, ulev, access->level, na->nick, nc->display, ci->name.c_str()); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") set access level " + << access->level << " to " << na->nick << " (group " << nc->display << ") on channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_LEVEL_CHANGED, nc->display, chan, level); return MOD_CONT; } @@ -243,7 +244,8 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, na->nick, level)); - alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", Config.s_ChanServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, ulev, level, na->nick, nc->display, ci->name.c_str()); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") set access level " + << level << " to " << na->nick << " (group " << nc->display << ") on channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display, ci->name.c_str(), level); } else if (cmd == "DEL") @@ -280,7 +282,8 @@ class CommandCSAccess : public Command } else { - alog("%s: %s!%s@%s (level %d) deleted access of user%s %s on %s", Config.s_ChanServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, get_access(u, ci), deleted == 1 ? "" : "s", nick, chan); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) + << ") deleted access of user" << (deleted == 1 ? " " : "s ") << nick << " on " << chan; if (deleted == 1) notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_DELETED_ONE, ci->name.c_str()); else @@ -310,7 +313,8 @@ class CommandCSAccess : public Command else { notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_DELETED, access->nc->display, ci->name.c_str()); - alog("%s: %s!%s@%s (level %d) deleted access of %s (group %s) on %s", Config.s_ChanServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, get_access(u, ci), na->nick, access->nc->display, chan); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) + << ") deleted access of " << na->nick << " (group " << access->nc->display << ") on " << chan; access->nc = NULL; access->in_use = 0; deleted = 1; @@ -403,10 +407,7 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u)); notice_lang(Config.s_ChanServ, u, CHAN_ACCESS_CLEAR, ci->name.c_str()); - alog("%s: %s!%s@%s (level %d) cleared access list on %s", - Config.s_ChanServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, - get_access(u, ci), chan); - + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << " cleared access list on " << chan; } else this->OnSyntaxError(u, ""); @@ -473,9 +474,8 @@ class CommandCSLevels : public Command if (stricmp(levelinfo[i].name, what) == 0) { ci->levels[levelinfo[i].what] = level; - alog("%s: %s!%s@%s set level %s on channel %s to %d", - Config.s_ChanServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, - levelinfo[i].name, ci->name.c_str(), level); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " set level " << levelinfo[i].name + << " on channel " << ci->name << " to " << level; notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_CHANGED, levelinfo[i].name, chan, level); return MOD_CONT; @@ -489,9 +489,8 @@ class CommandCSLevels : public Command if (stricmp(levelinfo[i].name, what) == 0) { ci->levels[levelinfo[i].what] = ACCESS_INVALID; - alog("%s: %s!%s@%s disabled level %s on channel %s", - Config.s_ChanServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, - levelinfo[i].name, ci->name.c_str()); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " disabled level " << levelinfo[i].name + << " on channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_DISABLED, levelinfo[i].name, chan); return MOD_CONT; @@ -536,8 +535,7 @@ class CommandCSLevels : public Command } else if (cmd == "RESET") { reset_levels(ci); - alog("%s: %s!%s@%s reset levels definitions on channel %s", - Config.s_ChanServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, ci->name.c_str()); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " reset levels definitions on channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_LEVELS_RESET, chan); } else { this->OnSyntaxError(u, ""); diff --git a/src/core/cs_drop.c b/src/core/cs_drop.c index 7c085ea1a..1a94d9ff6 100644 --- a/src/core/cs_drop.c +++ b/src/core/cs_drop.c @@ -70,9 +70,8 @@ class CommandCSDrop : public Command ircdproto->SendSQLineDel(ci->name.c_str()); } - alog("%s: Channel %s dropped by %s!%s@%s (founder: %s)", - Config.s_ChanServ, ci->name.c_str(), u->nick.c_str(), u->GetIdent().c_str(), - u->host, (ci->founder ? ci->founder->display : "(none)")); + Alog() << Config.s_ChanServ << ": Channel " << ci->name << " dropped by " << u->GetMask() << " (founder: " + << (ci->founder ? ci->founder->display : "(none)") << ")"; delete ci; diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c index 57a0b552b..64a707c8f 100644 --- a/src/core/cs_forbid.c +++ b/src/core/cs_forbid.c @@ -55,7 +55,7 @@ class CommandCSForbid : public Command ci = new ChannelInfo(chan); if (!ci) { - alog("%s: Valid FORBID for %s by %s failed", Config.s_ChanServ, ci->name.c_str(), u->nick.c_str()); + Alog() << Config.s_ChanServ << ": Valid FORBID for " << ci->name << " by " << u->nick << " failed"; notice_lang(Config.s_ChanServ, u, CHAN_FORBID_FAILED, chan); return MOD_CONT; } @@ -91,7 +91,7 @@ class CommandCSForbid : public Command ircdproto->SendSQLine(ci->name, reason ? reason : "Forbidden"); } - alog("%s: %s set FORBID for channel %s", Config.s_ChanServ, u->nick.c_str(), ci->name.c_str()); + Alog() << Config.s_ChanServ << ": " << u->nick << " set FORBID for channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_FORBID_SUCCEEDED, chan); FOREACH_MOD(I_OnChanForbidden, OnChanForbidden(ci)); diff --git a/src/core/cs_register.c b/src/core/cs_register.c index d934afb6e..67c4d0ff7 100644 --- a/src/core/cs_register.c +++ b/src/core/cs_register.c @@ -55,7 +55,7 @@ class CommandCSRegister : public Command notice_lang(Config.s_ChanServ, u, u->nc->channelcount > Config.CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, Config.CSMaxReg); else if (!(ci = new ChannelInfo(chan))) { - alog("%s: makechan() failed for REGISTER %s", Config.s_ChanServ, chan); + Alog() << Config.s_ChanServ << ": makechan() failed for REGISTER " << chan; notice_lang(Config.s_ChanServ, u, CHAN_REGISTRATION_FAILED); } else @@ -76,7 +76,7 @@ class CommandCSRegister : public Command ci->bi = NULL; ++ci->founder->channelcount; - alog("%s: Channel '%s' registered by %s!%s@%s", Config.s_ChanServ, chan, u->nick.c_str(), u->GetIdent().c_str(), u->host); + Alog() << Config.s_ChanServ << ": Channel '" << chan << "' registered by " << u->GetMask(); notice_lang(Config.s_ChanServ, u, CHAN_REGISTERED, chan, u->nick.c_str()); /* Implement new mode lock */ diff --git a/src/core/cs_set.c b/src/core/cs_set.c index 158987acd..2d8981072 100644 --- a/src/core/cs_set.c +++ b/src/core/cs_set.c @@ -42,9 +42,8 @@ class CommandCSSet : public Command return MOD_CONT; } - alog("%s: Changing founder of %s from %s to %s by %s!%s@%s", - Config.s_ChanServ, ci->name.c_str(), ci->founder->display, nc->display, u->nick.c_str(), - u->GetIdent().c_str(), u->host); + Alog() << Config.s_ChanServ << ": Changing founder of " << ci->name << " from " << ci->founder->display + << " to " << nc->display << " by " << u->GetMask(); /* Founder and successor must not be the same group */ if (nc == ci->successor) @@ -88,10 +87,9 @@ class CommandCSSet : public Command else nc = NULL; - alog("%s: Changing successor of %s from %s to %s by %s!%s@%s", - Config.s_ChanServ, ci->name.c_str(), - (ci->successor ? ci->successor->display : "none"), - (nc ? nc->display : "none"), u->nick.c_str(), u->GetIdent().c_str(), u->host); + Alog() << Config.s_ChanServ << ": Changing successor of " << ci->name << " from " + << (ci->successor ? ci->successor->display : "none") + << " to " << (nc ? nc->display : "none") << " by " << u->GetMask(); ci->successor = nc; @@ -500,16 +498,14 @@ class CommandCSSet : public Command ci->SetFlag(CI_XOP); } - alog("%s: %s!%s@%s enabled XOP for %s", Config.s_ChanServ, u->nick.c_str(), - u->GetIdent().c_str(), u->host, ci->name.c_str()); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " enabled XOP for " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_SET_XOP_ON, ci->name.c_str()); } else if (param == "OFF") { ci->UnsetFlag(CI_XOP); - alog("%s: %s!%s@%s disabled XOP for %s", Config.s_ChanServ, u->nick.c_str(), - u->GetIdent().c_str(), u->host, ci->name.c_str()); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " disabled XOP for " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_SET_XOP_OFF, ci->name.c_str()); } else diff --git a/src/core/cs_suspend.c b/src/core/cs_suspend.c index 03a058629..d356e36e2 100644 --- a/src/core/cs_suspend.c +++ b/src/core/cs_suspend.c @@ -76,14 +76,14 @@ class CommandCSSuspend : public Command if (Config.WallForbid) ircdproto->SendGlobops(findbot(Config.s_ChanServ), "\2%s\2 used SUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str()); - alog("%s: %s set SUSPEND for channel %s", Config.s_ChanServ, u->nick.c_str(), ci->name.c_str()); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " set SUSPEND for channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_SUSPEND_SUCCEEDED, chan); FOREACH_MOD(I_OnChanSuspend, OnChanSuspend(ci)); } else { - alog("%s: Valid SUSPEND for %s by %s failed", Config.s_ChanServ, ci->name.c_str(), u->nick.c_str()); + Alog() << Config.s_ChanServ << ": Valid SUSPEND for " << ci->name << " by " << u->GetMask() << " failed"; notice_lang(Config.s_ChanServ, u, CHAN_SUSPEND_FAILED, chan); } return MOD_CONT; @@ -146,14 +146,14 @@ class CommandCSUnSuspend : public Command if (Config.WallForbid) ircdproto->SendGlobops(findbot(Config.s_ChanServ), "\2%s\2 used UNSUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str()); - alog("%s: %s set UNSUSPEND for channel %s", Config.s_ChanServ, u->nick.c_str(), ci->name.c_str()); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " set UNSUSPEND for channel " << ci->name; notice_lang(Config.s_ChanServ, u, CHAN_UNSUSPEND_SUCCEEDED, chan); FOREACH_MOD(I_OnChanUnsuspend, OnChanUnsuspend(ci)); } else { - alog("%s: Valid UNSUSPEND for %s by %s failed", Config.s_ChanServ, chan, u->nick.c_str()); + Alog() << Config.s_ChanServ << ": Valid UNSUSPEND for " << chan << " by " << u->nick << " failed"; notice_lang(Config.s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan); } return MOD_CONT; diff --git a/src/core/cs_topic.c b/src/core/cs_topic.c index 8b700a7c5..67546d8e8 100644 --- a/src/core/cs_topic.c +++ b/src/core/cs_topic.c @@ -55,7 +55,7 @@ class CommandCSTopic : public Command c->topic_time = ci->last_topic_time; if (!check_access(u, ci, CA_TOPIC)) - alog("%s: %s!%s@%s changed topic of %s as services admin.", Config.s_ChanServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, c->name.c_str()); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " changed topic of " << c->name << " as services admin."; if (ircd->join2set && whosends(ci) == findbot(Config.s_ChanServ)) { ircdproto->SendJoin(findbot(Config.s_ChanServ), c->name.c_str(), c->creation_time); diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c index 021d8c3a9..130f62943 100644 --- a/src/core/cs_xop.c +++ b/src/core/cs_xop.c @@ -189,7 +189,9 @@ class XOPBase : public Command access->creator = u->nick; } - alog("%s: %s!%s@%s (level %d) %s access level %d to %s (group %s) on channel %s", Config.s_ChanServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, ulev, change ? "changed" : "set", level, na->nick, nc->display, ci->name.c_str()); + Alog() << Config.s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") " + << (change ? "changed" : "set") << " access level " << level << " to " << na->nick + << " (group " << nc->display << ") on channel " << ci->name; if (!change) { diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index 564cd9a35..039f19674 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -127,7 +127,7 @@ static void ReadDatabase(Module *m = NULL) } catch (const char *err) { - alog("[db_plain}: %s", err); + Alog() << "[db_plain}: " << err; } } else if (na && Type == MD_NA) @@ -143,7 +143,7 @@ static void ReadDatabase(Module *m = NULL) } catch (const char *err) { - alog("[db_plain}: %s", err); + Alog() << "[db_plain}: " << err; } } else if (bi && Type == MD_BI) @@ -159,7 +159,7 @@ static void ReadDatabase(Module *m = NULL) } catch (const char *err) { - alog("[db_plain}: %s", err); + Alog() << "[db_plain}: " << err; } } else if (ci && Type == MD_CH) @@ -175,7 +175,7 @@ static void ReadDatabase(Module *m = NULL) } catch (const char *err) { - alog("[db_plain}: %s", err); + Alog() << "[db_plain}: " << err; } } } @@ -397,8 +397,7 @@ static void LoadNickCore(const std::vector ¶ms) nc->memos.memomax = atoi(params[3].c_str()); nc->channelcount = atoi(params[4].c_str()); - if (debug > 1) - alog("[db_plain]: Loaded NickCore %s", nc->display); + Alog(LOG_DEBUG_2) << "[db_plain]: Loaded NickCore " << nc->display; } static void LoadNickAlias(const std::vector ¶ms) @@ -406,7 +405,7 @@ static void LoadNickAlias(const std::vector ¶ms) NickCore *nc = findcore(params[0].c_str()); if (!nc) { - alog("[db_plain]: Unable to find core %s", params[0].c_str()); + Alog() << "[db_plain]: Unable to find core " << params[0]; return; } @@ -416,8 +415,7 @@ static void LoadNickAlias(const std::vector ¶ms) na->last_seen = strtol(params[3].c_str(), NULL, 10); - if (debug > 1) - alog("[db_plain}: Loaded nickalias for %s", na->nick); + Alog(LOG_DEBUG_2) << "[db_plain}: Loaded nickalias for " << na->nick; } static void LoadBotInfo(const std::vector ¶ms) @@ -429,8 +427,7 @@ static void LoadBotInfo(const std::vector ¶ms) bi->chancount = atol(params[5].c_str()); bi->real = sstrdup(params[6].c_str()); - if (debug > 1) - alog("[db_plain]: Loaded botinfo for %s", bi->nick.c_str()); + Alog(LOG_DEBUG_2) << "[db_plain]: Loaded botinfo for " << bi->nick; } static void LoadChanInfo(const std::vector ¶ms) @@ -450,8 +447,7 @@ static void LoadChanInfo(const std::vector ¶ms) ci->memos.memomax = atoi(params[4].c_str()); - if (debug > 1) - alog("[db_plain]: loaded channel %s", ci->name.c_str()); + Alog(LOG_DEBUG_2) << "[db_plain]: loaded channel " << ci->name; } static void LoadOperInfo(const std::vector ¶ms) @@ -651,7 +647,7 @@ class DBPlain : public Module ci->founder = findcore(params[0].c_str()); if (!ci->founder) { - alog("[db_plain]: Deleting founderless channel %s", ci->name.c_str()); + Alog() << "[db_plain]: Deleting founderless channel " << ci->name; delete ci; ci = NULL; throw "no founder"; diff --git a/src/core/enc_md5.c b/src/core/enc_md5.c index 488fd5754..cc187b3bc 100644 --- a/src/core/enc_md5.c +++ b/src/core/enc_md5.c @@ -356,8 +356,7 @@ class EMD5 : public Module b64_encode(digest, 16, cpass, 1000); buf.append(cpass); - if (debug > 1) - alog("debug: (enc_md5) hashed password %s to %s ", src.c_str(), buf.c_str()); + Alog(LOG_DEBUG_2) << "(enc_md5) hashed password from [" << src << "] to [" << buf << "]"; dest.assign(buf); return EVENT_ALLOW; } diff --git a/src/core/enc_none.c b/src/core/enc_none.c index 2a5237662..8cd375428 100644 --- a/src/core/enc_none.c +++ b/src/core/enc_none.c @@ -30,8 +30,7 @@ class ENone : public Module char cpass[1000]; b64_encode(src.c_str(), src.size(), cpass, 1000); buf.append(cpass); - if (debug > 1) - alog("debug: (enc_none) hashed password from [%s] to [%s]", src.c_str(), buf.c_str()); + Alog(LOG_DEBUG_2) << "(enc_none) hashed password from [" << src << "] to [" << buf << "]"; dest.assign(buf); return EVENT_ALLOW; } diff --git a/src/core/enc_old.c b/src/core/enc_old.c index a04ec75e9..1a4e671f0 100644 --- a/src/core/enc_old.c +++ b/src/core/enc_old.c @@ -361,8 +361,7 @@ class EOld : public Module b64_encode(digest2, 16, cpass, 1000); buf.append(cpass); - if (debug > 1) - alog("debug: (enc_old) hashed password from [%s] to [%s]", src.c_str(), buf.c_str()); + Alog(LOG_DEBUG_2) << "(enc_old) hashed password from [" << src << "] to [" << buf << "]"; dest.assign(buf); return EVENT_ALLOW; } diff --git a/src/core/enc_sha1.c b/src/core/enc_sha1.c index bcf289f0a..95f7083ee 100644 --- a/src/core/enc_sha1.c +++ b/src/core/enc_sha1.c @@ -211,8 +211,7 @@ class ESHA1 : public Module b64_encode(digest, 20, cpass, 1000); buf.append(cpass); - if (debug > 1) - alog("debug: (enc_sha1) hashed password from [%s] to [%s] ", src.c_str(), buf.c_str()); + Alog(LOG_DEBUG_2) << "(enc_sha1) hashed password from [" << src << "] to [" << buf << "]"; dest.assign(buf); return EVENT_ALLOW; } diff --git a/src/core/enc_sha256.c b/src/core/enc_sha256.c index b37c574ec..307e905d9 100644 --- a/src/core/enc_sha256.c +++ b/src/core/enc_sha256.c @@ -297,8 +297,7 @@ class ESHA256 : public Module b64_encode(digest, SHA256_DIGEST_SIZE, cpass, 1000); buf << "sha256:" << cpass << ":" << GetSaltString(); - if (debug > 1) - alog("debug: (enc_sha256) hashed password from [%s] to [%s]", src.c_str(), buf.str().c_str()); + Alog(LOG_DEBUG_2) << "(enc_sha256) hashed password from [" << src << "] to [" << buf.str() << " ]"; dest.assign(buf.str()); return EVENT_ALLOW; diff --git a/src/core/hs_del.c b/src/core/hs_del.c index 25df95b31..b01debd02 100644 --- a/src/core/hs_del.c +++ b/src/core/hs_del.c @@ -33,7 +33,7 @@ class CommandHSDel : public Command notice_lang(Config.s_HostServ, u, NICK_X_FORBIDDEN, nick); return MOD_CONT; } - alog("vHost for user \002%s\002 deleted by oper \002%s\002", nick, u->nick.c_str()); + Alog() << "vHost for user \002" << nick << "\002 deleted by oper \002" << u->nick << "\002"; FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na)); na->hostinfo.RemoveVhost(); notice_lang(Config.s_HostServ, u, HOST_DEL, nick); diff --git a/src/core/hs_delall.c b/src/core/hs_delall.c index d938f40ac..4da35c684 100644 --- a/src/core/hs_delall.c +++ b/src/core/hs_delall.c @@ -42,7 +42,7 @@ class CommandHSDelAll : public Command na = static_cast(nc->aliases.list[i]); na->hostinfo.RemoveVhost(); } - alog("vHosts for all nicks in group \002%s\002 deleted by oper \002%s\002", nc->display, u->nick.c_str()); + Alog() << "vHosts for all nicks in group \002" << nc->display << "\002 deleted by oper \002" << u->nick << "\002"; notice_lang(Config.s_HostServ, u, HOST_DELALL, nc->display); } else diff --git a/src/core/hs_set.c b/src/core/hs_set.c index dd54cc121..e50723d0e 100644 --- a/src/core/hs_set.c +++ b/src/core/hs_set.c @@ -118,10 +118,10 @@ class CommandHSSet : public Command delete [] hostmask; return MOD_CONT; } - if (vIdent && ircd->vident) - alog("vHost for user \002%s\002 set to \002%s@%s\002 by oper \002%s\002", nick, vIdent, hostmask, u->nick.c_str()); - else - alog("vHost for user \002%s\002 set to \002%s\002 by oper \002%s\002", nick, hostmask, u->nick.c_str()); + Alog() << "vHost for user \002" << nick << "\002 set to \002" + << (vIdent && ircd->vident ? vIdent : "") << (vIdent && ircd->vident ? "@" : "") + << hostmask << " \002 by oper \002" << u->nick << "\002"; + na->hostinfo.SetVhost(vIdent ? vIdent : "", hostmask, u->nick); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); if (vIdent) diff --git a/src/core/hs_setall.c b/src/core/hs_setall.c index 2d22644dd..bb6f9cd15 100644 --- a/src/core/hs_setall.c +++ b/src/core/hs_setall.c @@ -116,10 +116,10 @@ class CommandHSSetAll : public Command tmp_time = time(NULL); - if (vIdent && ircd->vident) - alog("vHost for all nicks in group \002%s\002 set to \002%s@%s\002 by oper \002%s\002", nick, vIdent, hostmask, u->nick.c_str()); - else - alog("vHost for all nicks in group \002%s\002 set to \002%s\002 by oper \002%s\002", nick, hostmask, u->nick.c_str()); + Alog() << "vHost for all nicks in group \002" << nick << "\002 set to \002" + << (vIdent && ircd->vident ? vIdent : "") << (vIdent && ircd->vident ? "@" : "") + << hostmask << " \002 by oper \002" << u->nick << "\002"; + na->hostinfo.SetVhost(vIdent ? vIdent : "", hostmask, u->nick); HostServSyncVhosts(na); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); diff --git a/src/core/ms_rsend.c b/src/core/ms_rsend.c index b5847fc81..a4c06a4cd 100644 --- a/src/core/ms_rsend.c +++ b/src/core/ms_rsend.c @@ -58,8 +58,7 @@ class CommandMSRSend : public Command else { /* rsend has been disabled */ - if (debug) - alog("debug: MSMemoReceipt is set misconfigured to %d", Config.MSMemoReceipt); + Alog(LOG_DEBUG) << "MSMemoReceipt is set misconfigured to " << Config.MSMemoReceipt; notice_lang(Config.s_MemoServ, u, MEMO_RSEND_DISABLED); } diff --git a/src/core/ns_drop.c b/src/core/ns_drop.c index 96d573b84..152287b2f 100644 --- a/src/core/ns_drop.c +++ b/src/core/ns_drop.c @@ -44,7 +44,7 @@ class CommandNSDrop : public Command { if (Config.WallDrop) ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used DROP on \2%s\2", u->nick.c_str(), nick); - alog("%s: %s!%s@%s dropped nickname %s (e-mail: %s)", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, nr->nick, nr->email); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " dropped nickname " << nr->nick << " (e-mail: " << nr->email << ")"; delete nr; notice_lang(Config.s_NickServ, u, NICK_X_DROPPED, nick); } @@ -72,7 +72,7 @@ class CommandNSDrop : public Command if (ircd->sqline && (na->HasFlag(NS_FORBIDDEN))) ircdproto->SendSQLineDel(na->nick); - alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, na->nick, na->nc->display, na->nc->email ? na->nc->email : "none"); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " dropped nickname " << na->nick << " (group " << na->nc->display << ") (e-mail: " << (na->nc->email ? na->nc->email : "none") << ")"; delete na; FOREACH_MOD(I_OnNickDrop, OnNickDrop(my_nick ? my_nick : nick)); diff --git a/src/core/ns_forbid.c b/src/core/ns_forbid.c index 70c29fa32..18f3bf2aa 100644 --- a/src/core/ns_forbid.c +++ b/src/core/ns_forbid.c @@ -75,14 +75,14 @@ class CommandNSForbid : public Command if (Config.WallForbid) ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used FORBID on \2%s\2", u->nick.c_str(), nick); - alog("%s: %s set FORBID for nick %s", Config.s_NickServ, u->nick.c_str(), nick); + Alog() << Config.s_NickServ << ": " << u->nick << " set FORBID for nick " << nick; notice_lang(Config.s_NickServ, u, NICK_FORBID_SUCCEEDED, nick); FOREACH_MOD(I_OnNickForbidden, OnNickForbidden(na)); } else { - alog("%s: Valid FORBID for %s by %s failed", Config.s_NickServ, nick, u->nick.c_str()); + Alog() << Config.s_NickServ << ": Valid FORBID for " << nick << " by " << u->nick << " failed"; notice_lang(Config.s_NickServ, u, NICK_FORBID_FAILED, nick); } return MOD_CONT; diff --git a/src/core/ns_getemail.c b/src/core/ns_getemail.c index 94e5f8f8a..ab83936e4 100644 --- a/src/core/ns_getemail.c +++ b/src/core/ns_getemail.c @@ -33,7 +33,7 @@ class CommandNSGetEMail : public Command int i, j = 0; NickCore *nc; - alog("%s: %s!%s@%s used GETEMAIL on %s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, email.c_str()); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used GETEMAIL on " << email; for (i = 0; i < 1024; ++i) { for (nc = nclists[i]; nc; nc = nc->next) diff --git a/src/core/ns_getpass.c b/src/core/ns_getpass.c index f788287ab..026f0ecdc 100644 --- a/src/core/ns_getpass.c +++ b/src/core/ns_getpass.c @@ -33,7 +33,7 @@ class CommandNSGetPass : public Command { if ((nr = findrequestnick(nick))) { - alog("%s: %s!%s@%s used GETPASS on %s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, nick); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used GETPASS on " << nick; if (Config.WallGetpass) ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used GETPASS on \2%s\2", u->nick.c_str(), nick); notice_lang(Config.s_NickServ, u, NICK_GETPASS_PASSCODE_IS, nick, nr->passcode.c_str()); @@ -49,7 +49,7 @@ class CommandNSGetPass : public Command { if (enc_decrypt(na->nc->pass, tmp_pass) == 1) { - alog("%s: %s!%s@%s used GETPASS on %s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, nick); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used GETPASS on " << nick; if (Config.WallGetpass) ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used GETPASS on \2%s\2", u->nick.c_str(), nick); notice_lang(Config.s_NickServ, u, NICK_GETPASS_PASSWORD_IS, nick, tmp_pass.c_str()); diff --git a/src/core/ns_ghost.c b/src/core/ns_ghost.c index 6c4ee92fb..771dc6195 100644 --- a/src/core/ns_ghost.c +++ b/src/core/ns_ghost.c @@ -53,7 +53,7 @@ class CommandNSGhost : public Command notice_lang(Config.s_NickServ, u, ACCESS_DENIED); if (!res) { - alog("%s: GHOST: invalid password for %s by %s!%s@%s", Config.s_NickServ, nick, u->nick.c_str(), u->GetIdent().c_str(), u->host); + Alog() << Config.s_NickServ << ": GHOST: invalid password for " << nick << " by " << u->GetMask(); bad_password(u); } } diff --git a/src/core/ns_group.c b/src/core/ns_group.c index 857d65768..cb463d96f 100644 --- a/src/core/ns_group.c +++ b/src/core/ns_group.c @@ -69,12 +69,12 @@ class CommandNSGroup : public Command notice_lang(Config.s_NickServ, u, NICK_GROUP_PLEASE_WAIT, (Config.NSRegDelay + u->lastnickreg) - time(NULL)); else if (u->nc && u->nc->HasFlag(NI_SUSPENDED)) { - alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, target->nick); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " tried to use GROUP from SUSPENDED nick " << target->nick; notice_lang(Config.s_NickServ, u, NICK_X_SUSPENDED, u->nick.c_str()); } else if (target && target->nc->HasFlag(NI_SUSPENDED)) { - alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, target->nick); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " tried to use GROUP from SUSPENDED nick " << target->nick; notice_lang(Config.s_NickServ, u, NICK_X_SUSPENDED, target->nick); } else if (target->HasFlag(NS_FORBIDDEN)) @@ -87,7 +87,7 @@ class CommandNSGroup : public Command notice_lang(Config.s_NickServ, u, NICK_GROUP_TOO_MANY, target->nick, Config.s_NickServ, Config.s_NickServ); else if (enc_check_password(pass, target->nc->pass) != 1) { - alog("%s: Failed GROUP for %s!%s@%s (invalid password)", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host); + Alog() << Config.s_NickServ << ": Failed GROUP for " << u->GetMask() << " (invalid password)"; notice_lang(Config.s_Nick