diff options
Diffstat (limited to 'src')
80 files changed, 629 insertions, 944 deletions
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<void *>(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<ChannelModeName> *Status = new Flags<ChannelModeName>; 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<void *>(c)); + while (c) + { + if (stricmp(c->name.c_str(), chan) == 0) + { + Alog(LOG_DEBUG_3) << "findchan(" << chan << ") -> " << static_cast<void *>(c); return c; } c = c->next; } - if (debug >= 3) - alog("debug: findchan(%s) -> %p", chan, static_cast<void *>(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 <networkinfo:nicklen> directive. It is strongly"); - alog("adviced that you do configure this correctly in your services.conf"); + Alog() << "You have not defined the <networkinfo:nicklen> directive. It is strongly"; + Alog() << "adviced that you do configure this correctly in your services.conf"; data.Set(31); } else if (nicklen < 1) { - alog("<networkinfo:nicklen> has an invalid value; setting to %d", 31); + Alog() << "<networkinfo:nicklen> 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 <options:globaloncycle>", tag, value); + Alog() << "<" << tag << ":" << value << "> was undefined, disabling <options:globaloncycle>"; 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 <nickserv:defaults> can only be used when UsePrivmsg is set"); + if (!Config.UsePrivmsg) Alog() << "msg in <nickserv:defaults> 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<std::string> ¶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<std::string> ¶ms) @@ -406,7 +405,7 @@ static void LoadNickAlias(const std::vector<std::string> ¶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<std::string> ¶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<std::string> ¶ms) @@ -429,8 +427,7 @@ static void LoadBotInfo(const std::vector<std::string> ¶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<std::string> ¶ms) @@ -450,8 +447,7 @@ static void LoadChanInfo(const std::vector<std::string> ¶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<std::string> ¶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<NickAlias *>(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_NickServ, u, PASSWORD_INCORRECT); bad_password(u); } @@ -124,7 +124,9 @@ class CommandNSGroup : public Command FOREACH_MOD(I_OnNickGroup, OnNickGroup(u, target)); ircdproto->SetAutoIdentificationToken(u); - alog("%s: %s!%s@%s makes %s join group of %s (%s) (e-mail: %s)", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, u->nick.c_str(), target->nick, target->nc->display, (target->nc->email ? target->nc->email : "none")); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " makes " << u->nick + << " join group of " << target->nick << " (" << target->nc->display + << ") (e-mail: " << (target->nc->email ? target->nc->email : "none") << ")"; notice_lang(Config.s_NickServ, u, NICK_GROUP_JOINED, target->nick); u->lastnickreg = time(NULL); @@ -133,7 +135,7 @@ class CommandNSGroup : public Command } else { - alog("%s: makealias(%s) failed", Config.s_NickServ, u->nick.c_str()); + Alog() << Config.s_NickServ << ": makealias(" << u->nick << ") failed"; notice_lang(Config.s_NickServ, u, NICK_GROUP_FAILED); } } diff --git a/src/core/ns_identify.c b/src/core/ns_identify.c index 03b59aeea..44aebeb1a 100644 --- a/src/core/ns_identify.c +++ b/src/core/ns_identify.c @@ -52,7 +52,7 @@ class CommandNSIdentify : public Command notice_lang(Config.s_NickServ, u, NICK_ALREADY_IDENTIFIED); else if (!(res = enc_check_password(pass, na->nc->pass))) { - alog("%s: Failed IDENTIFY for %s!%s@%s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host); + Alog() << Config.s_NickServ << ": Failed IDENTIFY for " << u->nick << "!" << u->GetIdent() << "@" << u->host; notice_lang(Config.s_NickServ, u, PASSWORD_INCORRECT); bad_password(u); } @@ -62,7 +62,7 @@ class CommandNSIdentify : public Command { if (nick_identified(u)) { - alog("%s: %s!%s@%s logged out of account %s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, u->nc->display); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " logged out of account " << u->nc->display; } if (na->last_realname) @@ -78,7 +78,7 @@ class CommandNSIdentify : public Command FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(u)); - alog("%s: %s!%s@%s identified for nick %s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, u->nick.c_str()); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " identified for account " << u->nc->display; notice_lang(Config.s_NickServ, u, NICK_IDENTIFY_SUCCEEDED); if (ircd->vhost) do_on_id(u); diff --git a/src/core/ns_logout.c b/src/core/ns_logout.c index fcea30b3b..c36c46615 100644 --- a/src/core/ns_logout.c +++ b/src/core/ns_logout.c @@ -49,7 +49,7 @@ class CommandNSLogout : public Command } u2->isSuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */ - alog("%s: %s!%s@%s logged out nickname %s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, u2->nick.c_str()); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " logged out nickname " << u2->nick; /* Remove founder status from this user in all channels */ if (nick) diff --git a/src/core/ns_recover.c b/src/core/ns_recover.c index 320461fdd..059aee92d 100644 --- a/src/core/ns_recover.c +++ b/src/core/ns_recover.c @@ -61,7 +61,7 @@ class CommandNSRecover : public Command notice_lang(Config.s_NickServ, u, ACCESS_DENIED); if (!res) { - alog("%s: RECOVER: 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 << ": RECOVER: invalid password for " << nick << " by " << u->GetMask(); bad_password(u); } } diff --git a/src/core/ns_register.c b/src/core/ns_register.c index a62c5e82f..298256eba 100644 --- a/src/core/ns_register.c +++ b/src/core/ns_register.c @@ -26,7 +26,7 @@ class CommandNSConfirm : public Command if (!na) { - alog("%s: makenick(%s) failed", Config.s_NickServ, u->nick.c_str()); + Alog() << Config.s_NickServ << ": makenick(" << u->nick << ") failed"; notice_lang(Config.s_NickServ, u, NICK_REGISTRATION_FAILED); return MOD_CONT; } @@ -61,7 +61,7 @@ class CommandNSConfirm : public Command if (!force) { u->nc = na->nc; - alog("%s: '%s' registered by %s@%s (e-mail: %s)", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, nr->email ? nr->email : "none"); + Alog() << Config.s_NickServ << ": '" << u->nick << "' registered by " << u->GetIdent() << "@" << u->host << " (e-mail: " << (nr->email ? nr->email : "none") << ")"; if (Config.NSAddAccessOnReg) notice_lang(Config.s_NickServ, u, NICK_REGISTERED, u->nick.c_str(), na->nc->GetAccess(0).c_str()); else @@ -78,10 +78,8 @@ class CommandNSConfirm : public Command } else { - alog("%s: '%s' confirmed by %s!%s@%s (email: %s)", Config.s_NickServ, nr->nick, u->nick.c_str(), u->GetIdent().c_str(), u->host, nr->email ? nr->email : "none"); - + Alog() << Config.s_NickServ << ": '" << nr->nick << "' confirmed by " << u->GetMask() << " (email: " << (nr->email ? nr->email : "none") << " )"; notice_lang(Config.s_NickServ, u, NICK_FORCE_REG, nr->nick); - User *user = finduser(nr->nick); /* Delrequest must be called before validate_user */ delete nr; @@ -254,7 +252,7 @@ class CommandNSRegister : public CommandNSConfirm /* i.e. there's already such a nick regged */ if (na->HasFlag(NS_FORBIDDEN)) { - alog("%s: %s@%s tried to register FORBIDden nick %s", Config.s_NickServ, u->GetIdent().c_str(), u->host, u->nick.c_str()); + Alog() << Config.s_NickServ << ": " << u->GetIdent() << "@" << u->host << " tried to register FORBIDden nick " << u->nick; notice_lang(Config.s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick.c_str()); } else @@ -284,11 +282,11 @@ class CommandNSRegister : public CommandNSConfirm if (!do_sendregmail(u, nr)) { notice_lang(Config.s_NickServ, u, NICK_ENTER_REG_CODE, email, Config.s_NickServ); - alog("%s: sent registration verification code to %s", Config.s_NickServ, nr->email); + Alog() << Config.s_NickServ << ": sent registration verification code to " << nr->email; } else { - alog("%s: Unable to send registration verification mail", Config.s_NickServ); + Alog() << Config.s_NickServ << ": Unable to send registration verification mail"; notice_lang(Config.s_NickServ, u, NICK_REG_UNABLE); delete nr; return MOD_CONT; @@ -343,11 +341,11 @@ class CommandNSResend : public Command { nr->lastmail = time(NULL); notice_lang(Config.s_NickServ, u, NICK_REG_RESENT, nr->email); - alog("%s: re-sent registration verification code for %s to %s", Config.s_NickServ, nr->nick, nr->email); + Alog() << Config.s_NickServ << ": re-sent registration verification code for " << nr->nick << " to " << nr->email; } else { - alog("%s: Unable to re-send registration verification mail for %s", Config.s_NickServ, nr->nick); + Alog() << Config.s_NickServ << ": Unable to re-send registration verification mail for " << nr->nick; return MOD_CONT; } } diff --git a/src/core/ns_release.c b/src/core/ns_release.c index 867936f74..4424d7864 100644 --- a/src/core/ns_release.c +++ b/src/core/ns_release.c @@ -50,7 +50,7 @@ class CommandNSRelease : public Command notice_lang(Config.s_NickServ, u, ACCESS_DENIED); if (!res) { - alog("%s: RELEASE: 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 << ": RELEASE: invalid password for " << nick << " by " << u->GetMask(); bad_password(u); } } diff --git a/src/core/ns_resetpass.c b/src/core/ns_resetpass.c index d174864b1..fe39341e9 100644 --- a/src/core/ns_resetpass.c +++ b/src/core/ns_resetpass.c @@ -67,7 +67,7 @@ class CommandNSResetPass : public Command na->nc->Extend("ns_resetpass_code", new ExtensibleItemPointerArray<char>(sstrdup(passcode))); na->nc->Extend("ns_resetpass_time", new ExtensibleItemRegular<time_t>(time(NULL))); - alog("%s: %s!%s@%s used RESETPASS on %s (%s)", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, na->nick, na->nc->display); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used RESETPASS on " << na->nick << " (" << na->nc->display << ")"; notice_lang(Config.s_NickServ, u, NICK_RESETPASS_COMPLETE, na->nick); } @@ -144,8 +144,7 @@ class NSResetPass : public Module ircdproto->SetAutoIdentificationToken(u); FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(u)); - alog("%s: %s!%s@%s used CONFIRM with RESETPASS to forcefully identify to %s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, na->nick); - + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used CONFIRM with RESETPASS to forcefully identify to " << na->nick; notice_lang(Config.s_NickServ, u, NICK_CONFIRM_SUCCESS, Config.s_NickServ); if (ircd->vhost) @@ -156,7 +155,7 @@ class NSResetPass : public Module } else { - alog("%s: Invalid CONFIRM passcode for %s from %s!%s@%s", Config.s_NickServ, na->nick, u->nick.c_str(), u->GetIdent().c_str(), u->host); + Alog() << Config.s_NickServ << ": Invalid CONFIRM passcode for " << na->nick << " from " << u->GetMask(); notice_lang(Config.s_NickServ, u, NICK_CONFIRM_INVALID); bad_password(u); } diff --git a/src/core/ns_saset.c b/src/core/ns_saset.c index 5a86b1327..3ae40baea 100644 --- a/src/core/ns_saset.c +++ b/src/core/ns_saset.c @@ -83,7 +83,7 @@ private: buf = param.c_str(); /* conversion from ci::string to std::string */ if (enc_encrypt(buf, nc->pass)) { - alog("%s: Failed to encrypt password for %s (set)", Config.s_NickServ, nc->display); + Alog() << Config.s_NickServ << ": Failed to encrypt password for " << nc->display << " (set)"; notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_FAILED, nc->display); return MOD_CONT; } @@ -93,7 +93,7 @@ private: else notice_lang(Config.s_NickServ, u, NICK_SASET_PASSWORD_CHANGED, nc->display); - alog("%s: %s!%s@%s used SASET PASSWORD on %s (e-mail: %s)", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, nc->display, nc->email ? nc->email : "none"); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SASET PASSWORD on " << nc->display << " (e-mail: "<< (nc->email ? nc->email : "none") << ")"; if (Config.WallSetpass) ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used SASET PASSWORD on \2%s\2", u->nick.c_str(), nc->display); return MOD_CONT; @@ -139,7 +139,7 @@ private: return MOD_CONT; } - alog("%s: %s!%s@%s used SASET EMAIL on %s (e-mail: %s)", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, nc->display, nc->email ? nc->email : "none"); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SASET EMAIL on " << nc->display << " (e-mail: " << (nc->email ? nc->email : "none") << ")"; if (nc->email) delete [] nc->email; diff --git a/src/core/ns_sendpass.c b/src/core/ns_sendpass.c index f541ba9d5..9c3667047 100644 --- a/src/core/ns_sendpass.c +++ b/src/core/ns_sendpass.c @@ -61,7 +61,7 @@ class CommandNSSendPass : public Command MailEnd(mail); - alog("%s: %s!%s@%s used SENDPASS on %s", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, nick); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " used SENDPASS on " << nick; notice_lang(Config.s_NickServ, u, NICK_SENDPASS_OK, nick); } else diff --git a/src/core/ns_set.c b/src/core/ns_set.c index c2a60742d..054959a27 100644 --- a/src/core/ns_set.c +++ b/src/core/ns_set.c @@ -80,7 +80,7 @@ class CommandNSSet : public Command buf = param.c_str(); /* conversion from ci::string to std::string */ if (enc_encrypt(buf, nc->pass) < 0) { - alog("%s: Failed to encrypt password for %s (set)", Config.s_NickServ, nc->display); + Alog() << Config.s_NickServ << ": Failed to encrypt password for " << nc->display << " (set)"; notice_lang(Config.s_NickServ, u, NICK_SET_PASSWORD_FAILED); return MOD_CONT; } @@ -90,7 +90,7 @@ class CommandNSSet : public Command else notice_lang(Config.s_NickServ, u, NICK_SET_PASSWORD_CHANGED); - alog("%s: %s!%s@%s (e-mail: %s) changed its password.", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, nc->email ? nc->email : "none"); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " (e-mail: " << (nc->email ? nc->email : "none") << ") changed its password."; return MOD_CONT; } @@ -158,7 +158,7 @@ class CommandNSSet : public Command return MOD_CONT; } - alog("%s: %s!%s@%s (e-mail: %s) changed its e-mail to %s.", Config.s_NickServ, u->nick.c_str(), u->GetIdent().c_str(), u->host, nc->email ? nc->email : "none", param ? param : "none"); + Alog() << Config.s_NickServ << ": " << u->GetMask() << " (e-mail: " << (nc->email ? nc->email : "none") << ") changed its e-mail to " << (param ? param : "none"); if (nc->email) delete [] nc->email; diff --git a/src/core/ns_suspend.c b/src/core/ns_suspend.c index a9c6b65ba..a0e6a5967 100644 --- a/src/core/ns_suspend.c +++ b/src/core/ns_suspend.c @@ -81,14 +81,14 @@ class CommandNSSuspend : public Command if (Config.WallForbid) ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used SUSPEND on \2%s\2", u->nick.c_str(), nick); - alog("%s: %s set SUSPEND for nick %s", Config.s_NickServ, u->nick.c_str(), nick); + Alog() << Config.s_NickServ << ": " << u->nick << " set SUSPEND for nick " << nick; notice_lang(Config.s_NickServ, u, NICK_SUSPEND_SUCCEEDED, nick); FOREACH_MOD(I_OnNickSuspended, OnNickSuspend(na)) } else { - alog("%s: Valid SUSPEND for %s by %s failed", Config.s_NickServ, nick, u->nick.c_str()); + Alog() << Config.s_NickServ << ": Valid SUSPEND for " << nick << " by " << u->nick << " failed"; notice_lang(Config.s_NickServ, u, NICK_SUSPEND_FAILED, nick); } return MOD_CONT; @@ -149,14 +149,14 @@ class CommandNSUnSuspend : public Command if (Config.WallForbid) ircdproto->SendGlobops(findbot(Config.s_NickServ), "\2%s\2 used UNSUSPEND on \2%s\2", u->nick.c_str(), nick); - alog("%s: %s set UNSUSPEND for nick %s", Config.s_NickServ, u->nick.c_str(), nick); + Alog() << Config.s_NickServ << ": " << u->nick << " set UNSUSPEND for nick " << nick; notice_lang(Config.s_NickServ, u, NICK_UNSUSPEND_SUCCEEDED, nick); FOREACH_MOD(I_OnNickUnsuspended, OnNickUnsuspended(na)); } else { - alog("%s: Valid UNSUSPEND for %s by %s failed", Config.s_NickServ, nick, u->nick.c_str()); + Alog() << Config.s_NickServ << ": Valid UNSUSPEND for " << nick << " by " << u->nick << " failed"; notice_lang(Config.s_NickServ, u, NICK_UNSUSPEND_FAILED, nick); } return MOD_CONT; diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c index fdb2d236e..c06cf8c62 100644 --- a/src/core/os_defcon.c +++ b/src/core/os_defcon.c @@ -36,7 +36,7 @@ class DefConTimeout : public Timer { Config.DefConLevel = level; FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(level)); - alog("Defcon level timeout, returning to lvl %d", level); + Alog() << "Defcon level timeout, returning to lvl " << level; ircdproto->SendGlobops(findbot(Config.s_OperServ), getstring(OPER_DEFCON_WALL), Config.s_OperServ, level); if (Config.GlobalOnDefcon) @@ -95,7 +95,7 @@ class CommandOSDEFCON : public Command notice_lang(Config.s_OperServ, u, OPER_DEFCON_CHANGED, Config.DefConLevel); defcon_sendlvls(u); - alog("Defcon level changed to %d by Oper %s", newLevel, u->nick.c_str()); + Alog() << "Defcon level changed to " << newLevel << " by Oper " << u->nick; ircdproto->SendGlobops(findbot(Config.s_OperServ), getstring(OPER_DEFCON_WALL), u->nick.c_str(), newLevel); /* Global notice the user what is happening. Also any Message that the Admin would like to add. Set in config file. */ @@ -164,7 +164,7 @@ class OSDEFCON : public Module if (CheckDefCon(DEFCON_AKILL_NEW_CLIENTS)) { mask = "*@" + std::string(u->host); - alog("DEFCON: adding akill for %s", mask.c_str()); + Alog() << "DEFCON: adding akill for " << mask; add_akill(NULL, mask.c_str(), Config.s_OperServ, time(NULL) + Config.DefConAKILL, Config.DefConAkillReason ? Config.DefConAkillReason : @@ -375,7 +375,7 @@ void runDefCon() { if (Config.DefConChanModes[0] == '+' || Config.DefConChanModes[0] == '-') { - alog("DEFCON: setting %s on all chan's", Config.DefConChanModes); + Alog() << "DEFCON: setting " << Config.DefConChanModes << "on all chan's"; DefConModesSet = 1; MassChannelModes(findbot(Config.s_OperServ), Config.DefConChanModes); } @@ -390,7 +390,7 @@ void runDefCon() DefConModesSet = 0; if ((newmodes = defconReverseModes(Config.DefConChanModes))) { - alog("DEFCON: setting %s on all chan's", newmodes); + Alog() << "DEFCON: setting " << newmodes << " on all chan's"; MassChannelModes(findbot(Config.s_OperServ), newmodes); delete [] newmodes; } @@ -443,7 +443,7 @@ void defconParseModeString(const char *str) { if (cm->Type == MODE_STATUS || cm->Type == MODE_LIST || !cm->CanSet(NULL)) { - alog("DefConChanModes mode character '%c' cannot be locked", mode); + Alog() << "DefConChanModes mode character '" << mode << "' cannot be locked"; continue; } else if (add) @@ -457,7 +457,7 @@ void defconParseModeString(const char *str) if (!ss.GetToken(param)) { - alog("DefConChanModes mode character '%c' has no parameter while one is expected", mode); + Alog() << "DefConChanModes mode character '" << mode << "' has no parameter while one is expected"; continue; } @@ -489,7 +489,7 @@ void defconParseModeString(const char *str) { DefConModesOn.UnsetFlag(CMODE_REDIRECT); - alog("DefConChanModes must lock mode +l as well to lock mode +L"); + Alog() << "DefConChanModes must lock mode +l as well to lock mode +L"; } } @@ -500,7 +500,7 @@ void defconParseModeString(const char *str) if (DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_INVITE)) { DefConModesOn.UnsetFlag(CMODE_NOKNOCK); - alog("DefConChanModes must lock mode +i as well to lock mode +K"); + Alog() << "DefConChanModes must lock mode +i as well to lock mode +K"; } } } diff --git a/src/core/os_ignore.c b/src/core/os_ignore.c index b488ec1f1..2519cde96 100644 --- a/src/core/os_ignore.c +++ b/src/core/os_ignore.c @@ -181,8 +181,7 @@ class OSIgnore : public Module if (ign->time != 0 && ign->time <= now) { - if (debug) - alog("[os_ignore] debug: Expiring ignore entry %s", ign->mask); + Alog(LOG_DEBUG) << "[os_ignore] Expiring ignore entry " << ign->mask; if (ign->prev) ign->prev->next = ign->next; else if (ignore == ign) diff --git a/src/core/os_modunload.c b/src/core/os_modunload.c index e362d9e26..bf720c971 100644 --- a/src/core/os_modunload.c +++ b/src/core/os_modunload.c @@ -34,7 +34,7 @@ class CommandOSModUnLoad : public Command return MOD_CONT; } - alog("Trying to unload module [%s]", name); + Alog() << "Trying to unload module [" << name << "]"; status = ModuleManager::UnloadModule(m, u); diff --git a/src/core/os_news.c b/src/core/os_news.c index 853c81d31..69d0fa808 100644 --- a/src/core/os_news.c +++ b/src/core/os_news.c @@ -89,7 +89,7 @@ static void DisplayNews(User *u, NewsType Type) msg = NEWS_RANDOM_TEXT; else { - alog("news: Invalid type (%d) to display_news()", Type); + Alog() << "news: Invalid type (" << Type << ") to display_news()"; return; } @@ -285,7 +285,7 @@ class NewsBase : public Command msgs = findmsgs(type, &type_name); if (!msgs) { - alog("news: Invalid type to do_news()"); + Alog() << "news: Invalid type to do_news()"; return MOD_CONT; } @@ -461,15 +461,14 @@ class OSNews : public Module for (std::vector<NewsItem *>::iterator it = News.begin(); it != News.end(); ++it) { NewsItem *n = *it; - - char buf[512], *ntype; + char buf[512]; const char* ntype; if (n->type == NEWS_LOGON) ntype = "LOGON"; else if (n->type == NEWS_RANDOM) ntype = "RANDOM"; else if (n->type == NEWS_OPER) ntype = "OPER"; - snprintf(buf, sizeof(buf), "OS NEWS %d %ld %s %s :%s", n->num, n->time, n->who.c_str(), ntype, n->Text.c_str()); + snprintf(buf, sizeof(buf), "OS NEWS %d %ld %s %s :%s", n->num, n->time, n->who.c_str(), ntype, n->Text.c_str()); Write(buf); } } diff --git a/src/core/os_set.c b/src/core/os_set.c index e216d3a1d..7be3a67f0 100644 --- a/src/core/os_set.c +++ b/src/core/os_set.c @@ -75,7 +75,7 @@ class CommandOSSet : public Command if (setting == "ON") { readonly = 1; - alog("Read-only mode activated"); + Alog() << "Read-only mode activated"; close_log(); notice_lang(Config.s_OperServ, u, OPER_SET_READONLY_ON); } @@ -83,7 +83,7 @@ class CommandOSSet : public Command { readonly = 0; open_log(); - alog("Read-only mode deactivated"); + Alog() << "Read-only mode deactivated"; notice_lang(Config.s_OperServ, u, OPER_SET_READONLY_OFF); } else @@ -117,12 +117,12 @@ class CommandOSSet : public Command ircdproto->SendJoin(findbot(Config.s_GlobalNoticer), Config.LogChannel, c ? c->creation_time : time(NULL)); } LogChan = true; - alog("Now sending log messages to %s", Config.LogChannel); + Alog() << "Now sending log messages to " << Config.LogChannel; notice_lang(Config.s_OperServ, u, OPER_SET_LOGCHAN_ON, Config.LogChannel); } else if (Config.LogChannel && setting == "OFF") { - alog("No longer sending log messages to a channel"); + Alog() << "No longer sending log messages to a channel"; if (ircd->join2msg) ircdproto->SendPart(findbot(Config.s_GlobalNoticer), findchan(Config.LogChannel), NULL); LogChan = false; @@ -155,14 +155,14 @@ class CommandOSSet : public Command { u->isSuperAdmin = 1; notice_lang(Config.s_OperServ, u, OPER_SUPER_ADMIN_ON); - alog("%s: %s is a SuperAdmin ", Config.s_OperServ, u->nick.c_str()); + Alog() << Config.s_OperServ << ": " << u->nick << " is a SuperAdmin"; ircdproto->SendGlobops(findbot(Config.s_OperServ), getstring(OPER_SUPER_ADMIN_WALL_ON), u->nick.c_str()); } else if (setting == "OFF") { u->isSuperAdmin = 0; notice_lang(Config.s_OperServ, u, OPER_SUPER_ADMIN_OFF); - alog("%s: %s is no longer a SuperAdmin", Config.s_OperServ, u->nick.c_str()); + Alog() << Config.s_OperServ << ": " << u->nick << " is no longer a SuperAdmin"; ircdproto->SendGlobops(findbot(Config.s_OperServ), getstring(OPER_SUPER_ADMIN_WALL_OFF), u->nick.c_str()); } else @@ -184,19 +184,19 @@ class CommandOSSet : public Command if (setting == "ON") { debug = 1; - alog("Debug mode activated"); + Alog() << "Debug mode activated"; notice_lang(Config.s_OperServ, u, OPER_SET_DEBUG_ON); } else if (setting == "OFF" || (setting[0] == '0' && !atoi(setting.c_str()))) { - alog("Debug mode deactivated"); + Alog() << "Debug mode deactivated"; debug = 0; notice_lang(Config.s_OperServ, u, OPER_SET_DEBUG_OFF); } else if (isdigit(setting[0]) && atoi(setting.c_str()) > 0) { debug = atoi(setting.c_str()); - alog("Debug mode activated (level %d)", debug); + Alog() << "Debug mode activated (level " << debug << ")"; notice_lang(Config.s_OperServ, u, OPER_SET_DEBUG_LEVEL, debug); } else @@ -218,13 +218,13 @@ class CommandOSSet : public Command if (setting == "ON") { noexpire = 1; - alog("No expire mode activated"); + Alog() << "No expire mode activated"; notice_lang(Config.s_OperServ, u, OPER_SET_NOEXPIRE_ON); } else if (setting == "OFF") { noexpire = 0; - alog("No expire mode deactivated"); + Alog() << "No expire mode deactivated"; notice_lang(Config.s_OperServ, u, OPER_SET_NOEXPIRE_OFF); } else diff --git a/src/core/ss_main.c b/src/core/ss_main.c index b37cbafab..8ff8080b9 100644 --- a/src/core/ss_main.c +++ b/src/core/ss_main.c @@ -47,10 +47,10 @@ class SSMain : public Module statserv = findbot("StatServ"); if (!statserv) { - alog("Creating SS"); + Alog() << "Creating SS"; statserv = new BotInfo("StatServ", Config.ServiceUser, Config.ServiceHost, "Stats Service"); } - alog("Done creating SS"); + Alog() << "Done creating SS"; statserv->cmdTable = cmdTable; } diff --git a/src/encrypt.c b/src/encrypt.c index 34fb2d023..00d2ad805 100644 --- a/src/encrypt.c +++ b/src/encrypt.c @@ -55,7 +55,7 @@ int enc_decrypt(const std::string &src, std::string &dest) size_t pos = src.find(":"); if (pos == std::string::npos) { - alog("Error: enc_decrypt() called with invalid password string (%s)", src.c_str()); + Alog() << "Error: enc_decrypt() called with invalid password string (" << src << ")"; return -1; } std::string hashm(src.begin(), src.begin()+pos); @@ -80,7 +80,7 @@ int enc_check_password(std::string &plaintext, std::string &password) size_t pos = password.find(":"); if (pos == std::string::npos) { - alog("Error: enc_check_password() called with invalid password string (%s)", password.c_str()); + Alog() << "Error: enc_check_password() called with invalid password string (" << password << ")"; return 0; } hashm.assign(password.begin(), password.begin()+pos); diff --git a/src/init.c b/src/init.c index c6e870e5b..659e9be11 100644 --- a/src/init.c +++ b/src/init.c @@ -69,7 +69,7 @@ static int set_group() setgid(gr->gr_gid); return 0; } else { - alog("Unknown group `%s'\n", RUNGROUP); + Alog() << "Unknown group `" << RUNGROUP << "'"; return -1; } #else @@ -428,7 +428,7 @@ int init_secondary(int ac, char **av) { WSADATA wsa; if (WSAStartup(MAKEWORD(1, 1), &wsa)) { - alog("Failed to initialized WinSock library"); + Alog() << "Failed to initialized WinSock library"; return -1; } } @@ -436,7 +436,7 @@ int init_secondary(int ac, char **av) char *winver = GetWindowsVersion(); - alog("%s is not a supported version of Windows", winver); + Alog() << winver << " is not a supported version of Windows"; delete [] winver; @@ -444,7 +444,7 @@ int init_secondary(int ac, char **av) } if (!nofork) { - alog("Launching Anope into the background"); + Alog() << "Launching Anope into the background"; FreeConsole(); } #endif @@ -453,14 +453,9 @@ int init_secondary(int ac, char **av) write_pidfile(); /* Announce ourselves to the logfile. */ - if (debug || readonly) { - alog("Anope %s (ircd protocol: %s) starting up (options:%s%s)", - version_number, version_protocol, - debug ? " debug" : "", readonly ? " readonly" : ""); - } else { - alog("Anope %s (ircd protocol: %s) starting up", - version_number, version_protocol); - } + Alog() << "Anope " << version_number << " (ircd protocol: " << version_protocol << ") starting up" + << (debug || readonly ? " (options:" : "") << (debug ? " debug" : "") + << (readonly ? " readonly" : "") << (debug || readonly ? ")" : ""); start_time = time(NULL); @@ -480,8 +475,7 @@ int init_secondary(int ac, char **av) /* Initialize multi-language support */ lang_init(); - if (debug) - alog("debug: Loaded languages"); + Alog(LOG_DEBUG) << "Loaded languages"; /* Initialize subservices */ @@ -501,10 +495,10 @@ int init_secondary(int ac, char **av) add_entropy_userkeys(); /* Load up databases */ - alog("Loading databases..."); + Alog() << "Loading databases..."; EventReturn MOD_RESULT; FOREACH_RESULT(I_OnLoadDatabase, OnLoadDatabase()); - alog("Databases loaded"); + Alog() << "Databases loaded"; // XXX: this is duplicated in type loading. for (std::list<std::pair<std::string, std::string> >::iterator it = Config.Opers.begin(); it != Config.Opers.end(); it++) @@ -516,7 +510,7 @@ int init_secondary(int ac, char **av) if (!na) { // Nonexistant nick - alog("Oper nick %s is not registered", nick.c_str()); + Alog() << "Oper nick '" << nick << "' is not registered"; continue; } @@ -531,7 +525,7 @@ int init_secondary(int ac, char **av) 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; } } @@ -574,7 +568,7 @@ int init_secondary(int ac, char **av) uplink_server = *curr_uplink; servsock = conn(uplink_server->host, uplink_server->port, Config.LocalHost, Config.LocalPort); if (servsock >= 0) { - alog("Connected to Server %d (%s:%d)", servernum, uplink_server->host, uplink_server->port); + Alog() << "Connected to Server " << servernum << " (" << uplink_server->host << ":" << uplink_server->port << ")"; break; } } diff --git a/src/language.c b/src/language.c index 550aedc2f..7e152254f 100644 --- a/src/language.c +++ b/src/language.c @@ -68,10 +68,7 @@ static void load_lang(int index, const char *filename) FILE *f; int32 num, i; - if (debug) { - alog("debug: Loading language %d from file `languages/%s'", - index, filename); - } + Alog(LOG_DEBUG) << "Loading language " << index << " from file `languages/" << filename << "'"; snprintf(buf, sizeof(buf), "languages/%s", filename); #ifndef _WIN32 if (!(f = fopen(buf, "r"))) { @@ -81,12 +78,11 @@ static void load_lang(int index, const char *filename) log_perror("Failed to load language %d (%s)", index, filename); return; } else if (read_int32(&num, f) < 0) { - alog("Failed to read number of strings for language %d (%s)", - index, filename); + Alog() << "Failed to read number of strings for language " << index << "(" << filename << ")"; return; } else if (num != NUM_STRINGS) { - alog("Warning: Bad number of strings (%d, wanted %d) " - "for language %d (%s)", num, NUM_STRINGS, index, filename); + Alog() << "Warning: Bad number of strings (" << num << " , wanted " << NUM_STRINGS << ") " + << "for language " << index << " (" << filename << ")"; } langtexts[index] = new char *[NUM_STRINGS]; if (num > NUM_STRINGS) @@ -95,9 +91,9 @@ static void load_lang(int index, const char *filename) int32 pos, len; fseek(f, i * 8 + 4, SEEK_SET); if (read_int32(&pos, f) < 0 || read_int32(&len, f) < 0) { - alog("Failed to read entry %d in language %d (%s) TOC", - i, index, filename); - while (--i >= 0) { + Alog() << "Failed to read entry " << i << " in language " << index << " (" << filename << ") TOC"; + while (--i >= 0) + { if (langtexts[index][i]) delete [] langtexts[index][i]; } @@ -108,8 +104,7 @@ static void load_lang(int index, const char *filename) if (len == 0) { langtexts[index][i] = NULL; } else if (len >= 65536) { - alog("Entry %d in language %d (%s) is too long (over 64k)--" - "corrupt TOC?", i, index, filename); + Alog() << "Entry " << i << " in language " << index << " (" << filename << ") is too long (over 64k) -- corrupt TOC?"; while (--i >= 0) { if (langtexts[index][i]) delete [] langtexts[index][i]; @@ -118,8 +113,7 @@ static void load_lang(int index, const char *filename) langtexts[index] = NULL; return; } else if (len < 0) { - alog("Entry %d in language %d (%s) has negative length--" - "corrupt TOC?", i, index, filename); + Alog() << "Entry " << i << " in language " << index << " (" << filename << ") has negative length -- corrupt TOC?"; while (--i >= 0) { if (langtexts[index][i]) delete [] langtexts[index][i]; @@ -131,8 +125,7 @@ static void load_lang(int index, const char *filename) langtexts[index][i] = new char[len + 1]; fseek(f, pos, SEEK_SET); if (fread(langtexts[index][i], 1, len, f) != len) { - alog("Failed to read string %d in language %d (%s)", - i, index, filename); + Alog() << "Failed to read string " << i << " in language " << index << "(" << filename << ")"; while (--i >= 0) { if (langtexts[index][i]) delete [] langtexts[index][i]; @@ -147,43 +147,6 @@ char *log_gettimestamp() /*************************************************************************/ -/* Log stuff to the log file with a datestamp. Note that errno is - * preserved by this routine and log_perror(). - */ - -void alog(const char *fmt, ...) -{ - va_list args; - char *buf; - int errno_save = errno; - char str[BUFSIZE]; - - checkday(); - - if (!fmt) { - return; - } - - va_start(args, fmt); - vsnprintf(str, sizeof(str), fmt, args); - va_end(args); - - buf = log_gettimestamp(); - - if (logfile) { - fprintf(logfile, "%s %s\n", buf, str); - } - if (nofork) { - fprintf(stderr, "%s %s\n", buf, str); - } - if (Config.LogChannel && LogChan && !debug && findchan(Config.LogChannel)) { - ircdproto->SendPrivmsg(findbot(Config.s_GlobalNoticer), Config.LogChannel, "%s", str); - } - errno = errno_save; -} - -/*************************************************************************/ - /* Like alog(), but tack a ": " and a system error message (as returned by * strerror()) onto the end. */ @@ -292,3 +255,38 @@ void fatal_perror(const char *fmt, ...) exit(1); } +Alog::Alog(LogLevel val) +{ + if (val > debug) + logit = false; + else + { + logit = true; + if (val >= LOG_DEBUG) + buf << "Debug: "; + } +} + +Alog::~Alog() +{ + if (!logit) + return; + + char *tbuf; + int errno_save = errno; + + checkday(); + + tbuf = log_gettimestamp(); + + if (logfile) { + fprintf(logfile, "%s %s\n", tbuf, buf.str().c_str()); + } + if (nofork) { + fprintf(stderr, "%s %s\n", tbuf, buf.str().c_str()); + } + if (Config.LogChannel && LogChan && !debug && findchan(Config.LogChannel)) { + ircdproto->SendPrivmsg(findbot(Config.s_GlobalNoticer), Config.LogChannel, "%s", buf.str().c_str()); + } + errno = errno_save; +} diff --git a/src/main.c b/src/main.c index 264d2e48c..cb649a939 100644 --- a/src/main.c +++ b/src/main.c @@ -111,8 +111,7 @@ extern void expire_all() FOREACH_MOD(I_OnPreDatabaseExpire, OnPreDatabaseExpire()); - if (debug) - alog("debug: Running expire routines"); + Alog(LOG_DEBUG) << "Running expire routines"; expire_nicks(); expire_chans(); expire_requests(); @@ -137,8 +136,7 @@ void save_databases() { EventReturn MOD_RESULT; FOREACH_RESULT(I_OnSaveDatabase, OnSaveDatabase()); - if (debug) - alog("debug: Saving FFF databases"); + Alog(LOG_DEBUG) << "Saving FFF databases"; } /*************************************************************************/ @@ -150,7 +148,7 @@ void do_restart_services() expire_all(); save_databases(); } - alog("Restarting"); + Alog() << "Restarting"; FOREACH_MOD(I_OnPreRestart, OnPreRestart()); @@ -187,7 +185,7 @@ static void services_shutdown() if (!quitmsg) quitmsg = "Terminating, reason unknown"; - alog("%s", quitmsg); + Alog() << quitmsg; if (started) { ircdproto->SendSquit(Config.ServerName, quitmsg); if (uplink) @@ -229,7 +227,7 @@ void sighandler(int signum) #ifndef _WIN32 if (signum == SIGHUP) { - alog("Received SIGHUP: Saving Databases & Rehash Configuration"); + Alog() << "Received SIGHUP: Saving Databases & Rehash Configuration"; expire_all(); save_databases(); @@ -252,7 +250,7 @@ void sighandler(int signum) signal(SIGHUP, SIG_IGN); #endif - alog("Received SIGTERM, exiting."); + Alog() << "Received SIGTERM, exiting."; expire_all(); save_databases(); @@ -265,7 +263,7 @@ void sighandler(int signum) if (nofork) { signal(SIGINT, SIG_IGN); - alog("Received SIGINT, exiting."); + Alog() << "Received SIGINT, exiting."; expire_all(); save_databases(); quitmsg = "Shutting down on SIGINT"; @@ -292,7 +290,7 @@ void sighandler(int signum) } else { - alog("%s", quitmsg); + Alog() << quitmsg; } exit(1); @@ -423,14 +421,14 @@ int main(int ac, char **av, char **envp) rlimit rl; if (getrlimit(RLIMIT_CORE, &rl) == -1) { - alog("Failed to getrlimit()!"); + Alog() << "Failed to getrlimit()!"; } else { rl.rlim_cur = rl.rlim_max; if (setrlimit(RLIMIT_CORE, &rl) == -1) { - alog("setrlimit() failed, cannot increase coredump size"); + Alog() << "setrlimit() failed, cannot increase coredump size"; } } } @@ -441,8 +439,7 @@ int main(int ac, char **av, char **envp) while (!quitting) { time_t t = time(NULL); - if (debug >= 2) - alog("debug: Top of main loop"); + Alog(LOG_DEBUG_2) << "Top of main loop"; // Never fear. noexpire/readonly are checked in expire_all(). if (save_data || t - last_expire >= Config.ExpireTimeout) diff --git a/src/memory.c b/src/memory.c index 630fab6e4..c3ef73f7a 100644 --- a/src/memory.c +++ b/src/memory.c @@ -100,7 +100,7 @@ char *sstrdup(const char *src) abort(); strcpy(ret, src); } else { - alog("sstrdup() called with NULL-arg"); + Alog() << "sstrdup() called with NULL-arg"; abort(); } diff --git a/src/memoserv.c b/src/memoserv.c index 81448becd..1a60a88bc 100644 --- a/src/memoserv.c +++ b/src/memoserv.c @@ -83,10 +83,9 @@ void check_memos(User * u) NickCore *nc; unsigned i, newcnt = 0; - if (!u) { - if (debug) { - alog("debug: check_memos called with NULL values"); - } + if (!u) + { + Alog(LOG_DEBUG) << "check_memos called with NULL values"; return; } diff --git a/src/messages.c b/src/messages.c index f15e58f5c..fe8f46542 100644 --- a/src/messages.c +++ b/src/messages.c @@ -118,7 +118,7 @@ int m_privmsg(const char *source, const std::string &receiver, const char *msg) u = finduser(source); if (!u) { - alog("%s: user record for %s not found", msg, source); + Alog() << msg << ": user record for " << source << " not found"; /* Two lookups naughty, however, this won't happen often. -- w00t */ if (findbot(receiver)) { @@ -140,7 +140,7 @@ int m_privmsg(const char *source, const std::string &receiver, const char *msg) IgnoreData *ign = get_ignore(source); if (ign) { target = myStrGetToken(msg, ' ', 0); - alog("Ignored message from %s to %s using command %s", source, receiver.c_str(), target); + Alog() << "Ignored message from " << source << " to " << receiver << " using command " << target; delete [] target; return MOD_CONT; } @@ -158,9 +158,7 @@ int m_privmsg(const char *source, const std::string &receiver, const char *msg) return MOD_CONT; } else if (Config.UseStrictPrivMsg) { - if (debug) { - alog("Ignored PRIVMSG without @ from %s", source); - } + Alog(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << source; notice_lang(receiver, u, INVALID_TARGET, receiver.c_str(), receiver.c_str(), Config.ServerName, receiver.c_str()); return MOD_CONT; diff --git a/src/misc.c b/src/misc.c index a0e0dbadb..4c786a83c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -758,10 +758,8 @@ void EnforceQlinedNick(const std::string &nick, const char *killer) User *u2; if ((u2 = finduser(nick))) { - alog("Killed Q-lined nick: %s!%s@%s", u2->nick.c_str(), u2->GetIdent().c_str(), - u2->host); - kill_user(killer, u2->nick.c_str(), - "This nick is reserved for Services. Please use a non Q-Lined nick."); + Alog() << "Killed Q-lined nick: " << u2->GetMask(); + kill_user(killer, u2->nick.c_str(), "This nick is reserved for Services. Please use a non Q-Lined nick."); } } @@ -1021,9 +1019,7 @@ char *host_resolve(char *host) addr.s_addr = ip; ntoa(addr, ipbuf, sizeof(ipbuf)); ipreturn = sstrdup(ipbuf); - if (debug) { - alog("debug: resolved %s to %s", host, ipbuf); - } + Alog(LOG_DEBUG) << "resolved " << host << " to " << ipbuf; return ipreturn; } else { return ipreturn; diff --git a/src/modes.cpp b/src/modes.cpp index 31ec6545f..dfee2b214 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -70,7 +70,7 @@ void SetDefaultMLock() } else { - alog("Warning: Got default mlock mode %c with no param?", cm->ModeChar); + Alog() << "Warning: Got default mlock mode " << cm->ModeChar << " with no param?"; ptr->set(cm->Name, false); } } @@ -218,8 +218,7 @@ void ChannelModeBan::AddMask(Channel *chan, const char *mask) /* check for NULL values otherwise we will segfault */ if (!chan || !mask) { - if (debug) - alog("debug: add_ban called with NULL values"); + Alog(LOG_DEBUG) << "add_ban called with NULL values"; return; } @@ -247,8 +246,7 @@ void ChannelModeBan::AddMask(Channel *chan, const char *mask) } } - if (debug) - alog("debug: Added ban %s to channel %s", mask, chan->name.c_str()); + Alog(LOG_DEBUG) << "Added ban " << mask << " to channel " << chan->name; } /** Remove a ban from the channel @@ -270,8 +268,7 @@ void ChannelModeBan::DelMask(Channel *chan, const char *mask) { entry_delete(chan->bans, ban); - if (debug) - alog("debug: Deleted ban %s from channel %s", mask, chan->name.c_str()); + Alog(LOG_DEBUG) << "Deleted ban " << mask << " from channel " << chan->name; } if (chan->ci && (akick = is_stuck(chan->ci, mask))) @@ -288,8 +285,7 @@ void ChannelModeExcept::AddMask(Channel *chan, const char *mask) if (!chan || !mask) { - if (debug) - alog("debug: add_exception called with NULL values"); + Alog(LOG_DEBUG) << "add_exception called with NULL values"; return; } @@ -302,8 +298,7 @@ void ChannelModeExcept::AddMask(Channel *chan, const char *mask) if (!exception) fatal("Creating new exception entry failed"); - if (debug) - alog("debug: Added except %s to channel %s", mask, chan->name.c_str()); + Alog(LOG_DEBUG) << "Added except " << mask << " to channel " << chan->name; } /** Remove an except from the channel @@ -323,9 +318,7 @@ void ChannelModeExcept::DelMask(Channel *chan, const char *mask) if (exception) { entry_delete(chan->excepts, exception); - - if (debug) - alog("debug: Deleted except %s to channel %s", mask, chan->name.c_str()); + Alog(LOG_DEBUG) << "Deleted except " << mask << " to channel " << chan->name; } } @@ -339,8 +332,7 @@ void ChannelModeInvite::AddMask(Channel *chan, const char *mask) if (!chan || !mask) { - if (debug) - alog("debug: add_invite called with NULL values"); + Alog(LOG_DEBUG) << "add_invite called with NULL values"; return; } @@ -353,8 +345,7 @@ void ChannelModeInvite::AddMask(Channel *chan, const char *mask) if (!invite) fatal("Creating new exception entry failed"); - if (debug) - alog("debug: Added invite %s to channel %s", mask, chan->name.c_str()); + Alog(LOG_DEBUG) << "Added invite " << mask << " to channel " << chan->name; } @@ -375,9 +366,7 @@ void ChannelModeInvite::DelMask(Channel *chan, const char *mask) if (invite) { entry_delete(chan->invites, invite); - - if (debug) - alog("debug: Deleted invite %s to channel %s", mask, chan->name.c_str()); + Alog(LOG_DEBUG) << "Deleted invite " << mask << " to channel " << chan->name; } } diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index e9d63b12e..90c76319c 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -56,8 +56,7 @@ static int moduleCopyFile(const char *name, const char *output) return MOD_ERR_FILE_IO; #endif - if (debug) - alog("Runtime module location: %s", output); + Alog(LOG_DEBUG) << "Runtime module location: " << output; /* Linux/UNIX should ignore the b param, why do we still have seperate * calls for it here? -GD @@ -139,8 +138,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u) if (findModule(modname.c_str()) != NULL) return MOD_ERR_EXISTS; - if (debug) - alog("trying to load [%s]", modname.c_str()); + Alog(LOG_DEBUG) << "trying to load [" << modname << "]"; /* Generate the filename for the temporary copy of the module */ std::string pbuf; @@ -169,7 +167,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u) ano_module_t handle = dlopen(pbuf.c_str(), RTLD_LAZY); if (handle == NULL && (err = dlerror()) != NULL) { - alog("%s", err); + Alog() << err; return MOD_ERR_NOLOAD; } @@ -177,7 +175,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u) func = function_cast<Module *(*)(const std::string &, const std::string &)>(dlsym(handle, "init_module")); if (func == NULL && (err = dlerror()) != NULL) { - alog("No magical init function found, not an Anope module"); + Alog() << "No magical init function found, not an Anope module"; dlclose(handle); return MOD_ERR_NOLOAD; } @@ -202,7 +200,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u) } catch (ModuleException &ex) { - alog("Error while loading %s: %s", modname.c_str(), ex.GetReason()); + Alog() << "Error while loading " << modname << ": " << ex.GetReason(); return MOD_STOP; } @@ -212,35 +210,34 @@ int ModuleManager::LoadModule(const std::string &modname, User * u) Version v = m->GetVersion(); if (v.GetMajor() < VERSION_MAJOR || (v.GetMajor() == VERSION_MAJOR && v.GetMinor() < VERSION_MINOR)) { - alog("Module %s is compiled against an older version of Anope %d.%d, this is %d.%d", modname.c_str(), v.GetMajor(), v.GetMinor(), VERSION_MAJOR, VERSION_MINOR); + Alog() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << VERSION_MAJOR << "." << VERSION_MINOR; DeleteModule(m); return MOD_STOP; } else if (v.GetMajor() > VERSION_MAJOR || (v.GetMajor() == VERSION_MAJOR && v.GetMinor() > VERSION_MINOR)) { - alog("Module %s is compiled against a newer version of Anope %d.%d, this is %d.%d", modname.c_str(), v.GetMajor(), v.GetMinor(), VERSION_MAJOR, VERSION_MINOR); + Alog() << "Module " << modname << " is compiled against a newer version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << VERSION_MAJOR << "." << VERSION_MINOR; DeleteModule(m); return MOD_STOP; } else if (v.GetBuild() < VERSION_BUILD) { - alog("Module %s is compiled against an older revision of Anope %d, this is %d", modname.c_str(), v.GetBuild(), VERSION_BUILD); + Alog() << "Module " << modname << " is compiled against an older revision of Anope " << v.GetBuild() << ", this is " << VERSION_BUILD; } else if (v.GetBuild() > VERSION_BUILD) { - alog("Module %s is compiled against a newer revision of Anope %d, this is %d", modname.c_str(), v.GetBuild(), VERSION_BUILD); + Alog() << "Module " << modname << " is compiled against a newer revision of Anope " << v.GetBuild() << ", this is " << VERSION_BUILD; } else if (v.GetBuild() == VERSION_BUILD) { - if (debug) - alog("Module %s compiled against current version of Anope %d", modname.c_str(), v.GetBuild()); + Alog(LOG_DEBUG) << "Module " << modname << " compiled against current version of Anope " << v.GetBuild(); } if (m->type == PROTOCOL && IsOneOfModuleTypeLoaded(PROTOCOL)) { DeleteModule(m); - alog("You cannot load two protocol modules"); + Alog() << "You cannot load two protocol modules"; return MOD_STOP; } @@ -306,7 +303,7 @@ void ModuleManager::DeleteModule(Module *m) destroy_func = function_cast<void (*)(Module *)>(dlsym(m->handle, "destroy_module")); if (destroy_func == NULL && (err = dlerror()) != NULL) { - alog("No magical destroy function found, chancing delete..."); + Alog() << "No magical destroy function found, chancing delete..."; delete m; /* we just have to chance they haven't overwrote the delete operator then... */ } else @@ -317,7 +314,7 @@ void ModuleManager::DeleteModule(Module *m) if (handle) { if ((dlclose(handle)) != 0) - alog("%s", dlerror()); + Alog() << dlerror(); } } diff --git a/src/modules.c b/src/modules.c index 29376b558..7894c580b 100644 --- a/src/modules.c +++ b/src/modules.c @@ -60,7 +60,7 @@ int protocol_module_init() { int ret = 0; - alog("Loading IRCD Protocol Module: [%s]", Config.IRCDModule); + Alog() << "Loading IRCD Protocol Module: [" << Config.IRCDModule << "]"; ret = ModuleManager::LoadModule(Config.IRCDModule, NULL); if (ret == MOD_ERR_OK) @@ -74,7 +74,7 @@ int protocol_module_init() { if (!Config.Numeric) { - alog("This IRCd protocol requires a server id to be set in Anope's configuration."); + Alog() << "This IRCd protocol requires a server id to be set in Anope's configuration."; ret = -1; } else @@ -117,8 +117,7 @@ void Module::InsertLanguage(int langNumber, int ac, const char **av) { int i; - if (debug) - alog("debug: %s Adding %d texts for language %d", this->name.c_str(), ac, langNumber); + Alog(LOG_DEBUG) << this->name << "Adding " << ac << " texts for language " << langNumber; if (this->lang[langNumber].argc > 0) { this->DeleteLanguage(langNumber); @@ -261,7 +260,7 @@ int Module::AddCommand(CommandHash * cmdTable[], Command * c) status = internal_addCommand(this, cmdTable, c); if (status != MOD_ERR_OK) { - alog("ERROR! [%d]", status); + Alog() << "ERROR! [ "<< status << "]"; } return status; } @@ -469,18 +468,15 @@ int addMessage(MessageHash * msgTable[], Message * m, int pos) if (pos == 1) { m->next = current->m; current->m = m; - if (debug) - alog("debug: existing msg: (0x%p), new msg (0x%p)", - static_cast<void *>(m->next), static_cast<void *>(m)); + Alog(LOG_DEBUG) << "existing msg: ("<< static_cast<void *>(m->next) + << "), new msg (" << static_cast<void *>(m) << ")"; return MOD_ERR_OK; } else if (pos == 2) { tail = current->m; while (tail->next) tail = tail->next; - if (debug) - alog("debug: existing msg: (0x%p), new msg (0x%p)", - static_cast<void *>(tail), static_cast<void *>(m)); - tail->next = m; + Alog(LOG_DEBUG) << "existing msg: ("<< static_cast<void *>(tail) + << "), new msg (" << static_cast<void *>(m) << ")"; m->next = NULL; return MOD_ERR_OK; } else @@ -721,7 +717,7 @@ void Module::NoticeLang(const char *source, User * u, int number, ...) } delete [] buf; } else { - alog("%s: INVALID language string call, language: [%d], String [%d]", this->name.c_str(), mlang, number); + Alog() << this->name << ": INVALID language string call, language: [" << mlang << "], String [" << number << "]"; } } @@ -745,7 +741,7 @@ const char *Module::GetLangString(User * u, int number) * would happen! */ } else { - alog("%s: INVALID language string call, language: [%d], String [%d]", this->name.c_str(), mlang, number); + Alog() << this->name << ": INVALID language string call, language: [" << mlang << "], String [" << number << "]"; return ""; } } @@ -778,15 +774,13 @@ void ModuleRunTimeDirCleanUp() snprintf(dirbuf, BUFSIZE, "%s/modules/runtime", services_dir.c_str()); - if (debug) { - alog("debug: Cleaning out Module run time directory (%s) - this may take a moment please wait", dirbuf); - } + Alog(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment please wait"; + #ifndef _WIN32 - if ((dirp = opendir(dirbuf)) == NULL) { - if (debug) { - alog("debug: cannot open directory (%s)", dirbuf); - } + if ((dirp = opendir(dirbuf)) == NULL) + { + Alog(LOG_DEBUG) << "cannot open directory (" << dirbuf << ")"; return; } while ((dp = readdir(dirp)) != NULL) { @@ -802,10 +796,9 @@ void ModuleRunTimeDirCleanUp() closedir(dirp); #else /* Get the current working directory: */ - if (_getcwd(buffer, _MAX_PATH) == NULL) { - if (debug) { - alog("debug: Unable to set Current working directory"); - } + if (_getcwd(buffer, _MAX_PATH) == NULL) + { + Alog(LOG_DEBUG) << "Unable to set Current working directory"; } snprintf(szDir, sizeof(szDir), "%s\\%s\\*", buffer, dirbuf); @@ -824,15 +817,11 @@ void ModuleRunTimeDirCleanUp() } } } else { - if (debug) { - alog("debug: Invalid File Handle. GetLastError reports %d\n", static_cast<int>(GetLastError())); - } + Alog(LOG_DEBUG) << "Invalid File Handle. GetLastError() reports "<< static_cast<int>(GetLastError()); } FindClose(hList); #endif - if (debug) { - alog("debug: Module run time directory has been cleaned out"); - } + Alog(LOG_DEBUG) << "Module run time directory has been cleaned out"; } /* EOF */ diff --git a/src/modules/cs_appendtopic.c b/src/modules/cs_appendtopic.c index ee34c3b56..e94b23476 100644 --- a/src/modules/cs_appendtopic.c +++ b/src/modules/cs_appendtopic.c @@ -96,7 +96,7 @@ class CommandCSAppendTopic : 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_ChanServ << ": " << u->GetMask() << " changed topic of " << c->name << " as services admin."; if (ircd->join2set) { if (whosends(ci) == findbot(Config.s_ChanServ)) diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c index 39d936bca..9d752cd36 100644 --- a/src/modules/cs_enforce.c +++ b/src/modules/cs_enforce.c @@ -59,8 +59,7 @@ class CommandCSEnforce : public Command if (!(ci = c->ci)) return; - if (debug) - alog("debug: cs_enforce: Enforcing SECUREOPS on %s", c->name.c_str()); + Alog(LOG_DEBUG) << "[cs_enforce] Enforcing SECUREOPS on " << c->name; /* Dirty hack to allow chan_set_correct_modes to work ok. * We pretend like SECUREOPS is on so it doesn't ignore that @@ -98,8 +97,7 @@ class CommandCSEnforce : public Command if (!(ci = c->ci)) return; - if (debug) - alog("debug: cs_enforce: Enforcing RESTRICTED on %s", c->name.c_str()); + Alog(LOG_DEBUG) << "[cs_enforce] Enforcing RESTRICTED on " << c->name; old_nojoin_level = ci->levels[CA_NOJOIN]; if (ci->levels[CA_NOJOIN] < 0) @@ -131,8 +129,7 @@ class CommandCSEnforce : public Command if (!(ci = c->ci)) return; - if (debug) - alog("debug: cs_enforce: Enforcing mode +R on %s", c->name.c_str()); + Alog(LOG_DEBUG) << "[cs_enforce] Enforcing mode +R on " << c->name; for (CUserList::iterator it = c->users.begin(); it != c->users.end();) { diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c index 3938c5e9b..784fcc59d 100644 --- a/src/modules/hs_request.c +++ b/src/modules/hs_request.c @@ -170,7 +170,7 @@ class CommandHSRequest : public Command me->NoticeLang(Config.s_HostServ, u, LNG_REQUESTED); req_send_memos(u, vIdent, hostmask); - alog("New vHost Requested by %s", nick); + Alog() << "New vHost Requested by " << nick; } else notice_lang(Config.s_HostServ, u, HOST_NOREG, nick); @@ -223,7 +223,7 @@ class CommandHSActivate : public Command my_memo_lang(u, na->nick, 2, LNG_ACTIVATE_MEMO); me->NoticeLang(Config.s_HostServ, u, LNG_ACTIVATED, nick); - alog("Host Request for %s activated by %s", nick, u->nick.c_str()); + Alog() << "Host Request for " << nick << " activated by " << u->nick; } else me->NoticeLang(Config.s_HostServ, u, LNG_NO_REQUEST, nick); @@ -275,7 +275,7 @@ class CommandHSReject : public Command } me->NoticeLang(Config.s_HostServ, u, LNG_REJECTED, nick); - alog("Host Request for %s rejected by %s (%s)", nick, u->nick.c_str(), reason ? reason : ""); + Alog() << "Host Request for " << nick << " rejected by " << u->nick << " (" << (reason ? reason : "") << ")"; } else me->NoticeLang(Config.s_HostServ, u, LNG_NO_REQUEST, nick); @@ -762,7 +762,7 @@ void my_memo_lang(User *u, const char *name, int z, int number, ...) delete [] buf; } else - alog("%s: INVALID language string call, language: [%d], String [%d]", me->name.c_str(), lang, number); + Alog() << me->name << ": INVALID language string call, language: [" << lang << "], String [" << number << "]"; } void req_send_memos(User *u, char *vIdent, char *vHost) @@ -819,8 +819,7 @@ void my_load_config() HSRequestMemoOper = config.ReadFlag("hs_request", "memooper", "no", 0); HSRequestMemoSetters = config.ReadFlag("hs_request", "memosetters", "no", 0); - if (debug) - alog("debug: [hs_request] Set config vars: MemoUser=%d MemoOper=%d MemoSetters=%d", HSRequestMemoUser, HSRequestMemoOper, HSRequestMemoSetters); + Alog(LOG_DEBUG) << "[hs_request] Set config vars: MemoUser=" << HSRequestMemoUser << " MemoOper=" << HSRequestMemoOper << " MemoSetters=" << HSRequestMemoSetters; } MODULE_INIT(HSRequest) diff --git a/src/modules/ns_maxemail.c b/src/modules/ns_maxemail.c index ebbd9a1e5..4817c5003 100644 --- a/src/modules/ns_maxemail.c +++ b/src/modules/ns_maxemail.c @@ -166,9 +166,7 @@ void my_load_config() { ConfigReader config; NSEmailMax = config.ReadInteger("ns_maxemail", "maxemails", "0", 0, false); - - if (debug) - alog("debug: [ns_maxemail] NSEmailMax set to %d", NSEmailMax); + Alog(LOG_DEBUG) << "[ns_maxemail] NSEmailMax set to " << NSEmailMax; } MODULE_INIT(NSMaxEmail) diff --git a/src/modules/ns_noop_convert.c b/src/modules/ns_noop_convert.c index 48b4b26ad..8cc5d69e6 100644 --- a/src/modules/ns_noop_convert.c +++ b/src/modules/ns_noop_convert.c @@ -72,8 +72,8 @@ class NSNOOPConvert : public Module mLoadData(); - alog("ns_noop_convert: Your auto-op database has been converted and this module will now"); - alog("ns_noop_convert: unload itself. You can now remove this module from your config"); + Alog() << "ns_noop_convert: Your auto-op database has been converted and this module will now"; + Alog() << "ns_noop_convert: unload itself. You can now remove this module from your config"; } ~NSNOOPConvert() @@ -102,7 +102,7 @@ int mLoadData() /* will _never_ be this big thanks to the 512 limit of a message */ char buffer[2000]; if ((in = fopen(NSAutoOPDBName, "r")) == NULL) { - alog("ns_noop: WARNING: Can not open database file! (it might not exist, this is not fatal)"); + Alog() << "ns_noop: WARNING: Can not open database file! (it might not exist, this is not fatal)"; ret = 1; } else { while (fgets(buffer, 1500, in)) { @@ -138,11 +138,10 @@ int mLoadConfig(int argc, char **argv) NSAutoOPDBName = sstrdup(tmp.c_str()); if (tmp.empty()) { - alog("ns_noop: FATAL: Can't read required configuration directives!"); + Alog() << "ns_noop: FATAL: Can't read required configuration directives!"; return MOD_STOP; } else { - alog("ns_noop: Directive NSAutoOPDBName loaded (%s)...", - NSAutoOPDBName); + Alog() << "ns_noop: Directive NSAutoOPDBName loaded (" << NSAutoOPDBName << ")..."; } return MOD_CONT; diff --git a/src/nickcore.cpp b/src/nickcore.cpp index b009c25f8..0073e0d32 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -65,7 +65,7 @@ NickCore::~NickCore() nclists[HASH(this->display)] = this->next; /* Log .. */ - alog("%s: deleting nickname group %s", Config.s_NickServ, this->display); + Alog() << Config.s_NickServ << ": deleting nickname group " << this->display; /* Now we can safely free it. */ delete [] this->display; diff --git a/src/nickserv.c b/src/nickserv.c index 506e56ef4..8f4ceea1b 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -414,9 +414,7 @@ void expire_nicks() User *u = finduser(na->nick); if (u && (na->nc->HasFlag(NI_SECURE) ? nick_identified(u) : u->IsRecognized())) { - if (debug >= 2) - alog("debug: NickServ: updating last seen time for %s", - na->nick); + Alog(LOG_DEBUG_2) << "NickServ: updating last seen time for " << na->nick; na->last_seen = now; continue; } @@ -429,10 +427,8 @@ void expire_nicks() FOREACH_RESULT(I_OnPreNickExpire, OnPreNickExpire(na)); if (MOD_RESULT == EVENT_STOP) continue; - - alog("Expiring nickname %s (group: %s) (e-mail: %s)", - na->nick, na->nc->display, - (na->nc->email ? na->nc->email : "none")); + Alog() << "Expiring nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " + << (na->nc->email ? na->nc->email : "none") << ")"; tmpnick = sstrdup(na->nick); delete na; FOREACH_MOD(I_OnNickExpire, OnNickExpire(tmpnick)); @@ -454,7 +450,7 @@ void expire_requests() next = nr->next; if (Config.NSRExpire && now - nr->requested >= Config.NSRExpire) { - alog("Request for nick %s expiring", nr->nick); + Alog() << "Request for nick " << nr->nick << " expiring"; delete nr; } } @@ -471,10 +467,7 @@ NickRequest *findrequestnick(const char *nick) if (!*nick || !nick) { - if (debug) - { - alog("debug: findrequestnick() called with NULL values"); - } + Alog(LOG_DEBUG) << "findrequestnick() called with NULL values"; return NULL; } @@ -499,10 +492,7 @@ NickAlias *findnick(const char *nick) if (!nick || !*nick) { - if (debug) - { - alog("debug: findnick() called with NULL values"); - } + Alog(LOG_DEBUG) << "findnick() called with NULL values"; return NULL; } @@ -534,10 +524,7 @@ NickCore *findcore(const char *nick) if (!nick || !*nick) { - if (debug) - { - alog("debug: findcore() called with NULL values"); - } + Alog(LOG_DEBUG) << "findcore() called with NULL values"; return NULL; } @@ -633,10 +620,7 @@ void alpha_insert_alias(NickAlias * na) if (!na) { - if (debug) - { - alog("debug: alpha_insert_alias called with NULL values"); - } + Alog(LOG_DEBUG) << "alpha_insert_alias called with NULL values"; return; } @@ -665,10 +649,7 @@ void insert_core(NickCore * nc) if (!nc) { - if (debug) - { - alog("debug: insert_core called with NULL values"); - } + Alog(LOG_DEBUG) << "insert_core called with NULL values"; return; } @@ -687,10 +668,7 @@ void insert_requestnick(NickRequest * nr) int index = HASH(nr->nick); if (!nr) { - if (debug) - { - alog("debug: insert_requestnick called with NULL values"); - } + Alog(LOG_DEBUG) << "insert_requestnick called with NULL values"; return; } @@ -724,8 +702,7 @@ void change_core_display(NickCore * nc, const char *newdisplay) */ /* Log ... */ FOREACH_MOD(I_OnChangeCoreDisplay, OnChangeCoreDisplay(nc, newdisplay)); - alog("%s: changing %s nickname group display to %s", Config.s_NickServ, - nc->display, newdisplay); + Alog() << Config.s_NickServ << ": changing " << nc->display << " nickname group display to " << newdisplay; /* Remove the core from the list */ if (nc->next) @@ -857,7 +834,7 @@ void SetOperType(NickCore *nc) if (ot->GetName() == type) { nc->ot = ot; - alog("%s: Tied oper %s to type %s", Config.s_OperServ, nc->display, type.c_str()); + Alog() << Config.s_OperServ << ": Tied oper " << nc->display << " to type " << type; } } } diff --git a/src/operserv.c b/src/operserv.c index f348d3ff2..3f7a68df7 100644 --- a/src/operserv.c +++ b/src/operserv.c @@ -128,7 +128,7 @@ void operserv(User * u, char *buf) const char *cmd; const char *s; - alog("%s: %s: %s", Config.s_OperServ, u->nick.c_str(), buf); + Alog() << Config.s_OperServ << ": " << u->nick << ": " << buf; cmd = strtok(buf, " "); if (!cmd) { diff --git a/src/process.c b/src/process.c index 3165949da..2c85e1644 100644 --- a/src/process.c +++ b/src/process.c @@ -83,8 +83,7 @@ void add_ignore(const char *nick, time_t delta) if (ignore) ignore->prev = ign; ignore = ign; - if (debug) - alog("debug: Added new ignore entry for %s", mask); + Alog(LOG_DEBUG) << "Added new ignore entry for " << mask; } } @@ -139,9 +138,9 @@ IgnoreData *get_ignore(const char *nick) break; } /* Check whether the entry has timed out */ - if (ign && ign->time != 0 && ign->time <= now) { - if (debug) - alog("debug: Expiring ignore entry %s", ign->mask); + if (ign && ign->time != 0 && ign->time <= now) + { + Alog(LOG_DEBUG) << "Expiring ignore entry " << ign->mask; if (ign->prev) ign->prev->next = ign->next; else if (ignore == ign) @@ -153,7 +152,7 @@ IgnoreData *get_ignore(const char *nick) ign = NULL; } if (ign && debug) - alog("debug: Found ignore entry (%s) for %s", ign->mask, nick); + Alog(LOG_DEBUG) << "Found ignore entry (" << ign->mask << ") for " << nick; return ign; } @@ -197,8 +196,7 @@ int delete_ignore(const char *nick) /* No matching ignore found. */ if (!ign) return 0; - if (debug) - alog("Deleting ignore entry %s", ign->mask); + Alog(LOG_DEBUG) << "Deleting ignore entry " << ign->mask; /* Delete the entry and all references to it. */ if (ign->prev) ign->prev->next = ign->next; @@ -228,8 +226,7 @@ int clear_ignores() return 0; for (ign = ignore; ign; ign = next) { next = ign->next; - if (debug) - alog("Deleting ignore entry %s", ign->mask); + Alog(LOG_DEBUG) << "Deleting ignore entry " << ign->mask; delete [] ign->mask; delete ign; i++; @@ -302,9 +299,7 @@ void process() *cmd = '\0'; /* If debugging, log the buffer */ - if (debug) { - alog("debug: Received: %s", inbuf); - } + Alog(LOG_DEBUG) << "Received: " << inbuf; /* First make a copy of the buffer so we have the original in case we * crash - in that case, we want to know what we crashed on. */ @@ -338,17 +333,17 @@ void process() if (protocoldebug) { if (*source) - alog("debug: Source %s", source); + Alog() << "Source " << source; if (*cmd) - alog("debug: Token %s", cmd); + Alog() << "Token " << cmd; if (ac) { int i; for (i = 0; i < ac; i++) - alog("debug: av[%d] = %s", i, av[i]); + Alog() << "av[" << i << "] = " << av[i]; } else - alog("debug: av[0] = NULL"); + Alog() << "av[0] = NULL"; } /* Do something with the message. */ @@ -365,8 +360,7 @@ void process() } } } else { - if (debug) - alog("debug: unknown message from server (%s)", inbuf); + Alog(LOG_DEBUG) << "unknown message from server (" << inbuf << ")"; } /* Free argument list we created */ diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c index d3c92df86..4462ee4eb 100644 --- a/src/protocol/bahamut.c +++ b/src/protocol/bahamut.c @@ -129,9 +129,7 @@ void bahamut_cmd_capab() call on this function */ void bahamut_cmd_chghost(const char *nick, const char *vhost) { - if (debug) { - alog("debug: This IRCD does not support vhosting"); - } + Alog(LOG_DEBUG) << "This IRCD does not support vhosting"; } @@ -408,8 +406,7 @@ int anope_event_sjoin(const char *source, int ac, const char **av) User *u = finduser(source); if (!u) { - if (debug) - alog("debug: SJOIN for nonexistant user %s on %s", source, c->name.c_str()); + Alog(LOG_DEBUG) << "SJOIN for nonexistant user " << source << " on " << c->name; } else { @@ -449,7 +446,7 @@ int anope_event_sjoin(const char *source, int ac, const char **av) ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); if (!cm) { - alog("Recieved unknown mode prefix %c in SJOIN string", buf[0]); + Alog() << "Recieved unknown mode prefix " << buf[0] << " in SJOIN string"; continue; } @@ -459,8 +456,7 @@ int anope_event_sjoin(const char *source, int ac, const char **av) User *u = finduser(buf); if (!u) { - if (debug) - alog("debug: SJOIN for nonexistant user %s on %s", buf.c_str(), c->name.c_str()); + Alog(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; continue; } @@ -743,11 +739,8 @@ int anope_event_ping(const char *source, int ac, const char **av) int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } + if (ac >= 1) + Alog(LOG_DEBUG) << av[0]; return MOD_CONT; } diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index 85612f010..ffd34cb8f 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -446,8 +446,7 @@ int anope_event_fmode(const char *source, int ac, const char **av) if (n != 1) { newav[o] = av[n]; o++; - if (debug) - alog("Param: %s", newav[o - 1]); + Alog(LOG_DEBUG) << "Param: " << newav[o - 1]; } n++; } @@ -519,7 +518,7 @@ int anope_event_fjoin(const char *source, int ac, const char **av) if (cm) { - alog("Recieved unknown mode prefix %c in FJOIN string", buf[0]); + Alog() << "Recieved unknown mode prefix " << buf[0] << " in FJOIN string"; continue; } @@ -529,8 +528,7 @@ int anope_event_fjoin(const char *source, int ac, const char **av) User *u = finduser(buf); if (!u) { - if (debug) - alog("debug: FJOIN for nonexistant user %s on %s", buf.c_str(), c->name.c_str()); + Alog(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name; continue; } @@ -612,11 +610,9 @@ int anope_event_topic(const char *source, int ac, const char **av) Channel *c = findchan(av[0]); time_t topic_time = time(NULL); - 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 MOD_CONT; } @@ -720,10 +716,9 @@ int anope_event_setname(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETNAME for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "SETNAME for nonexistent user " << source; return MOD_CONT; } @@ -739,10 +734,9 @@ int anope_event_chgname(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: FNAME for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "FNAME for nonexistent user " << source; return MOD_CONT; } @@ -758,10 +752,9 @@ int anope_event_setident(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETIDENT for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; return MOD_CONT; } @@ -777,10 +770,9 @@ int anope_event_chgident(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGIDENT for nonexistent user %s", av[0]); - } + if (!u) + { + Alog(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0]; return MOD_CONT; } @@ -796,10 +788,9 @@ int anope_event_sethost(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETHOST for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "SETHOST for nonexistent user " << source; return MOD_CONT; } @@ -850,10 +841,9 @@ int anope_event_chghost(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: FHOST for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "FHOST for nonexistent user " << source; return MOD_CONT; } diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index f7f57971e..9762d115f 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -496,8 +496,7 @@ int anope_event_fmode(const char *source, int ac, const char **av) if (n != 1) { newav[o] = av[n]; o++; - if (debug) - alog("Param: %s", newav[o - 1]); + Alog(LOG_DEBUG) << "Param: " << newav[o - 1]; } n++; } @@ -582,7 +581,7 @@ int anope_event_fjoin(const char *source, int ac, const char **av) buf.erase(buf.begin()); if (!cm) { - alog("Recieved unknown mode prefix %c in FJOIN string", buf[0]); + Alog() << "Recieved unknown mode prefix " << buf[0] << " in FJOIN string"; continue; } @@ -593,8 +592,7 @@ int anope_event_fjoin(const char *source, int ac, const char **av) User *u = find_byuid(buf); if (!u) { - if (debug) - alog("debug: FJOIN for nonexistant user %s on %s", buf.c_str(), c->name.c_str()); + Alog(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name; continue; } @@ -685,11 +683,9 @@ int anope_event_topic(const char *source, int ac, const char **av) time_t topic_time = time(NULL); User *u = find_byuid(source); - 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) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; return MOD_CONT; } @@ -769,10 +765,9 @@ int anope_event_setname(const char *source, int ac, const char **av) User *u; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETNAME for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "SETNAME for nonexistent user " << source; return MOD_CONT; } @@ -785,10 +780,9 @@ int anope_event_chgname(const char *source, int ac, const char **av) User *u; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: FNAME for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "FNAME for nonexistent user " << source; return MOD_CONT; } @@ -801,10 +795,9 @@ int anope_event_setident(const char *source, int ac, const char **av) User *u; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETIDENT for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; return MOD_CONT; } @@ -817,10 +810,9 @@ int anope_event_chgident(const char *source, int ac, const char **av) User *u; u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGIDENT for nonexistent user %s", av[0]); - } + if (!u) + { + Alog(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0]; return MOD_CONT; } @@ -833,10 +825,9 @@ int anope_event_sethost(const char *source, int ac, const char **av) User *u; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETHOST for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "SETHOST for nonexistent user " << source; return MOD_CONT; } @@ -913,10 +904,9 @@ int anope_event_chghost(const char *source, int ac, const char **av) User *u; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: FHOST for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "FHOST for nonexistent user " << source; return MOD_CONT; } @@ -1173,7 +1163,7 @@ int anope_event_endburst(const char *source, int ac, const char **av) u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED); } - alog("Processed ENDBURST for %s", s->name); + Alog() << "Processed ENDBURST for " << s->name; finish_sync(s, 1); return MOD_CONT; diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c index 46431c38c..1fc7122e2 100644 --- a/src/protocol/ratbox.c +++ b/src/protocol/ratbox.c @@ -410,7 +410,7 @@ int anope_event_sjoin(const char *source, int ac, const char **av) ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); if (!cm) { - alog("Recieved unknown mode prefix %c in SJOIN string", buf[0]); + Alog() << "Recieved unknown mode prefix " << buf[0] << " in SJOIN string"; continue; } @@ -420,8 +420,7 @@ int anope_event_sjoin(const char *source, int ac, const char **av) User *u = find_byuid(buf); if (!u) { - if (debug) - alog("debug: SJOIN for nonexistant user %s on %s", buf.c_str(), c->name.c_str()); + Alog(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; continue; } @@ -534,10 +533,7 @@ int anope_event_topic(const char *source, int ac, const char **av) time_t topic_time = time(NULL); if (!c) { - if (debug) { - alog("debug: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } + Alog(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; return MOD_CONT; } @@ -582,11 +578,9 @@ int anope_event_tburst(const char *source, int ac, const char **av) c = findchan(av[0]); topic_time = strtol(av[1], NULL, 10); - 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) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; if (setter) delete [] setter; return MOD_CONT; @@ -876,11 +870,8 @@ int anope_event_bmask(const char *source, int ac, const char **av) int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } + if (ac >= 1) + Alog(LOG_DEBUG) << av[0]; return MOD_CONT; } diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index e2b66b2ea..ee906b1b8 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -662,10 +662,9 @@ int anope_event_setname(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETNAME for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "SETNAME for nonexistent user " << source; return MOD_CONT; } @@ -681,10 +680,9 @@ int anope_event_chgname(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGNAME for nonexistent user %s", av[0]); - } + if (!u) + { + Alog(LOG_DEBUG) << "CHGNAME for nonexistent user " << av[0]; return MOD_CONT; } @@ -700,10 +698,9 @@ int anope_event_setident(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETIDENT for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; return MOD_CONT; } @@ -718,10 +715,9 @@ int anope_event_chgident(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGIDENT for nonexistent user %s", av[0]); - } + if (!u) + { + Alog(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0]; return MOD_CONT; } @@ -737,10 +733,9 @@ int anope_event_sethost(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETHOST for nonexistent user %s", source); - } + if (!u) + { + Alog(LOG_DEBUG) << "SETHOST for nonexistent user " << source; return MOD_CONT; } @@ -856,10 +851,9 @@ int anope_event_chghost(const char *source, int ac, const char **av) return MOD_CONT; u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGHOST for nonexistent user %s", av[0]); - } + if (!u) + { + Alog(LOG_DEBUG) << "debug: CHGHOST for nonexistent user " << av[0]; return MOD_CONT; } @@ -917,15 +911,14 @@ int anope_event_whois(const char *source, int ac, const char **av) int anope_event_error(const char *source, int ac, const char **av) { - if (av[0]) { - if (debug) { - alog("debug: %s", av[0]); - } - if(strstr(av[0],"No matching link configuration")!=0) { - alog("Error: Your IRCD's link block may not setup correctly, please check unrealircd.conf"); - } + if (av[0]) + { + Alog(LOG_DEBUG) << av[0]; + if(strstr(av[0],"No matching link configuration")!=0) + Alog() << "Error: Your IRCD's link block may not setup correctly, please check unrealircd.conf"; } return MOD_CONT; + } int anope_event_sdesc(const char *source, int ac, const char **av) @@ -1063,7 +1056,7 @@ int anope_event_sjoin(const char *source, int ac, const char **av) ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); if (!cm) { - alog("Recieved unknown mode prefix %c in SJOIN string", buf[0]); + Alog() << "Recieved unknown mode prefix " << buf[0] << " in SJOIN string"; continue; } @@ -1073,8 +1066,7 @@ int anope_event_sjoin(const char *source, int ac, const char **av) User *u = finduser(buf); if (!u) { - if (debug) - alog("debug: SJOIN for nonexistant user %s on %s", buf.c_str(), c->name.c_str()); + Alog(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; continue; } diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 5f9437513..4460cc272 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -79,8 +79,7 @@ ChannelInfo::~ChannelInfo() ircdproto->SendMode(whosends(this), this->c, "-%c", ModeManager::FindChannelModeByName(CMODE_PERM)->ModeChar); } - if (debug) - alog("debug: Deleting channel %s", this->name.c_str()); + Alog(LOG_DEBUG) << "Deleting channel " << this->name; if (this->bi) this->bi->chancount--; diff --git a/src/send.c b/src/send.c index 4ece37986..a032b1f03 100644 --- a/src/send.c +++ b/src/send.c @@ -36,14 +36,12 @@ void send_cmd(const char *source, const char *fmt, ...) if (source) { sockprintf(servsock, ":%s %s\r\n", source, buf); - if (debug) - alog("debug: Sent: :%s %s", source, buf); + Alog(LOG_DEBUG) << "Sent: :" << source << " " << buf; } else { sockprintf(servsock, "%s\r\n", buf); - if (debug) - alog("debug: Sent: %s", buf); + Alog(LOG_DEBUG) << "Sent: "<< buf; } va_end(args); @@ -65,14 +63,12 @@ void send_cmd(const std::string &source, const char *fmt, ...) if (!source.empty()) { sockprintf(servsock, ":%s %s\r\n", source.c_str(), buf); - if (debug) - alog("debug: Sent: :%s %s", source.c_str(), buf); + Alog(LOG_DEBUG) << "Sent: :" << source << " " << buf; } else { sockprintf(servsock, "%s\r\n", buf); - if (debug) - alog("debug: Sent: %s", buf); + Alog(LOG_DEBUG) << "Sent: " << buf; } va_end(args); diff --git a/src/servers.c b/src/servers.c index e392715be..87f24e405 100644 --- a/src/servers.c +++ b/src/servers.c @@ -122,8 +122,7 @@ Server *new_server(Server * server_uplink, const char *name, const char *desc, { Server *serv; - if (debug) - alog("Creating %s(%s) uplinked to %s", name, suid, server_uplink ? server_uplink->name : "No uplink"); + Alog(LOG_DEBUG) << "Creating " << name << "(" << suid << ") uplinked to " << (server_uplink ? server_uplink->name : "No uplink"); serv = new Server; if (!name) name = ""; @@ -196,18 +195,14 @@ static void delete_server(Server * serv, const char *quitreason) User *u, *unext; NickAlias *na; - if (debug) - alog("Deleting %s(%s) uplinked to %s(%s)", serv->name, serv->suid, serv->uplink ? serv->uplink->name : "NOTHING", serv->uplink ? serv->uplink->suid : "NOSUIDUPLINK"); - if (!serv) { - if (debug) { - alog("debug: delete_server() called with NULL arg!"); - } + Alog(LOG_DEBUG) << "delete_server() called with NULL arg!"; return; } - if (debug) - alog("debug: delete_server() called for %s", serv->name); + Alog(LOG_DEBUG) << "delete_server() called, deleting " << serv->name << "(" << serv->suid << ") uplinked to " + << (serv->uplink ? serv->uplink->name : "NOTHING") << "(" + << (serv->uplink ? serv->uplink->suid : "NOSUIDUPLINK") << ")"; if (ircdcap->noquit || ircdcap->qs) { if ((uplink_capab & ircdcap->noquit) @@ -234,8 +229,7 @@ static void delete_server(Server * serv, const char *quitreason) } u = unext; } - if (debug) - alog("debug: delete_server() cleared all users"); + Alog(LOG_DEBUG) << "delete_server() cleared all users"; } } @@ -246,8 +240,7 @@ static void delete_server(Server * serv, const char *quitreason) s = snext; } - if (debug) - alog("debug: delete_server() cleared all servers"); + Alog(LOG_DEBUG) << "delete_server() cleared all servers"; delete [] serv->name; delete [] serv->desc; @@ -258,8 +251,7 @@ static void delete_server(Server * serv, const char *quitreason) if (serv->uplink->links == serv) serv->uplink->links = serv->next; - if (debug) - alog("debug: delete_server() completed"); + Alog(LOG_DEBUG) << "delete_server() completed"; } /*************************************************************************/ @@ -278,13 +270,11 @@ Server *findserver(Server * s, const char *name) return NULL; } - if (debug) - alog("findserver(%s)", name); + Alog(LOG_DEBUG) << "findserver(" << name << ")"; while (s && (stricmp(s->name, name) != 0)) { - if (debug >= 3) - alog("Compared %s, not a match", s->name); + Alog(LOG_DEBUG_3) << "Compared " << s->name << ", not a match"; if (s->links) { sl = findserver(s->links, name); @@ -303,8 +293,7 @@ Server *findserver(Server * s, const char *name) } } - if (debug) - alog("debug: findserver(%s) -> %p", name, static_cast<void *>(s)); + Alog(LOG_DEBUG) << "findserver(" << name << ") -> " << static_cast<void *>(s); return s; } @@ -324,13 +313,11 @@ Server *findserver_uid(Server * s, const char *name) return NULL; } - if (debug) - alog("debug: findserver_uid(%s)", name); + Alog(LOG_DEBUG) << "findserver_uid(" << name << ")"; while (s && s->suid && (stricmp(s->suid, name) != 0)) { - if (debug >= 3) - alog("Compared %s, not a match", s->suid); + Alog(LOG_DEBUG_3) << "Compared " << s->suid << ", not a match"; if (s->links) { sl = findserver_uid(s->links, name); @@ -349,8 +336,7 @@ Server *findserver_uid(Server * s, const char *name) } } - if (debug) - alog("debug: findserver_uid(%s) -> %p", name, static_cast<void *>(s)); + Alog(LOG_DEBUG) << "findserver_uid(" << name << ") -> " << static_cast<void *>(s); return s; } @@ -392,14 +378,8 @@ void do_server(const char *source, const char *servername, const char *hops, { Server *s, *newserver; - if (debug) { - if (!*source) { - alog("debug: Server introduced (%s)", servername); - } else { - alog("debug: Server introduced (%s) from %s", servername, - source); - } - } + Alog(LOG_DEBUG) << "Server introduced (" << servername << ")" << (*source ? " from " : "") << (*source ? source : ""); + if (source[0] == '\0') s = me_server; @@ -445,8 +425,9 @@ void do_squit(const char *source, int ac, const char **av) } else { s = findserver(servlist, av[0]); } - if (!s) { - alog("SQUIT for nonexistent server (%s)!!", av[0]); + if (!s) + { + Alog() << "SQUIT for nonexistent server (" << av[0] << ")!!"; return; } FOREACH_MOD(I_OnServerQuit, OnServerQuit(s)); @@ -467,9 +448,7 @@ void do_squit(const char *source, int ac, const char **av) if (ircdcap->unconnect) { if ((s->uplink == me_server) && (uplink_capab & ircdcap->unconnect)) { - if (debug) { - alog("debug: Sending UNCONNECT SQUIT for %s", s->name); - } + Alog(LOG_DEBUG) << "Sending UNCONNECT SQUIT for " << s->name; /* need to fix */ ircdproto->SendSquit(s->name, buf); } @@ -575,10 +554,9 @@ void finish_sync(Server * serv, int sync_links) /* Mark each server as in sync */ s = serv; do { - if (!is_sync(s)) { - if (debug) - alog("debug: Finishing sync for server %s", s->name); - + if (!is_sync(s)) + { + Alog(LOG_DEBUG) << "Finishing sync for server " << s->name; s->sync = SSYNC_DONE; } @@ -611,7 +589,7 @@ void finish_sync(Server * serv, int sync_links) // XXX: this doesn't actually match the description. finish_sync(), depending on the ircd, can be called multiple times // Perhaps this should be done if serv == serv_uplink? restore_unsynced_topics(); - alog("Server %s is done syncing", serv->name); + Alog() << "Server " << serv->name << " is done syncing"; } /*******************************************************************/ @@ -654,7 +632,7 @@ const char *ts6_uid_retrieve() { if (ircd->ts6 == 0) { - alog("TS6 not supported on this ircd"); + Alog(LOG_DEBUG) << "ts6_uid_retrieve(): TS6 not supported on this ircd"; return ""; } @@ -716,8 +694,7 @@ const char *ts6_sid_retrieve() { if (!ircd->ts6) { - if (debug) - alog("TS6 not supported on this ircd"); + Alog(LOG_DEBUG) << "ts6_sid_retrieve(): TS6 not supported on this ircd"; return ""; } diff --git a/src/sessions.c b/src/sessions.c index 867373f27..b0ca9b374 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -160,12 +160,10 @@ int add_session(const char *nick, const char *host, char *hostip) if (Config.MaxSessionKill && session->hits >= Config.MaxSessionKill) { char akillmask[BUFSIZE]; snprintf(akillmask, sizeof(akillmask), "*@%s", host); - add_akill(NULL, akillmask, Config.s_OperServ, - time(NULL) + Config.SessionAutoKillExpiry, - "Session limit exceeded"); + add_akill(NULL, akillmask, Config.s_OperServ, + time(NULL) + Config.SessionAutoKillExpiry, "Session limit exceeded"); ircdproto->SendGlobops(findbot(Config.s_OperServ), - "Added a temporary AKILL for \2%s\2 due to excessive connections", - akillmask); + "Added a temporary AKILL for \2%s\2 due to excessive connections", akillmask); } return 0; } else { @@ -194,31 +192,24 @@ void del_session(const char *host) Session *session; if (!Config.LimitSessions) { - if (debug) { - alog("debug: del_session called when LimitSessions is disabled"); - } + Alog(LOG_DEBUG) << "del_session called when LimitSessions is disabled"; return; } if (!host || !*host) { - if (debug) { - alog("debug: del_session called with NULL values"); - } + Alog(LOG_DEBUG) << "del_session called with NULL values"; return; } - if (debug >= 2) - alog("debug: del_session() called"); + Alog(LOG_DEBUG_2) << "del_session() called"; session = findsession(host); if (!session) { - if (debug) { - ircdproto->SendGlobops(findbot(Config.s_OperServ), - "WARNING: Tried to delete non-existant session: \2%s", - host); - alog("session: Tried to delete non-existant session: %s", - host); + if (debug) + { + ircdproto->SendGlobops(findbot(Config.s_OperServ), "WARNING: Tried to delete non-existant session: \2%s", host); + Alog(LOG_DEBUG) << "session: Tried to delete non-existant session: " << host; } return; } @@ -235,16 +226,14 @@ void del_session(const char *host) if (session->next) session->next->prev = session->prev; - if (debug >= 2) - alog("debug: del_session(): free session structure"); + Alog(LOG_DEBUG_2) << "del_session(): free session structure"; delete [] session->host; delete session; nsessions--; - if (debug >= 2) - alog("debug: del_session() done"); + Alog(LOG_DEBUG_2) << "del_session() done"; } diff --git a/src/slist.c b/src/slist.c index 986b09077..25efeb357 100644 --- a/src/slist.c +++ b/src/slist.c @@ -212,7 +212,7 @@ int slist_enum(SList * slist, const char *crange, slist_enumcb_t cb, ...) if (!range) { for (i = 0; i < slist->count; i++) { if (!slist->list[i]) { - alog("SList: warning: NULL pointer in the list (?)"); + Alog() << "SList: warning: NULL pointer in the list (?)"; continue; } @@ -247,7 +247,7 @@ int slist_enum(SList * slist, const char *crange, slist_enumcb_t cb, ...) } for (i = n1; i <= n2 && i > 0 && i <= slist->count; i++) { if (!slist->list[i - 1]) { - alog("SList: warning: NULL pointer in the list (?)"); + Alog() << "SList: warning: NULL pointer in the list (?)"; continue; } diff --git a/src/sockutil.c b/src/sockutil.c index d432dc9a0..b5125d142 100644 --- a/src/sockutil.c +++ b/src/sockutil.c @@ -82,9 +82,7 @@ static int buffered_read(ano_socket_t fd, char *buf, int len) maxread = read_buftop - read_bufend; nread = ano_sockread(fd, read_bufend, maxread); errno_save = ano_sockgeterr(); - if (debug >= 3) - alog("debug: buffered_read wanted %d, got %d", maxread, - nread); + Alog(LOG_DEBUG_3) << "buffered_read wanted " << maxread << " got " << nread; if (nread <= 0) break; read_bufend += nread; @@ -114,10 +112,7 @@ static int buffered_read(ano_socket_t fd, char *buf, int len) } } total_read += len - left; - if (debug >= 4) { - alog("debug: buffered_read(%d,%p,%d) returning %d", - fd, buf, len, len - left); - } + Alog(LOG_DEBUG_4) << "buffered_read(" << fd << "," << static_cast<void *>(buf) << ", " << len << ") returning " << len - left; ano_sockseterr(errno_save); return len - left; } @@ -159,9 +154,7 @@ static int buffered_read_one(ano_socket_t fd) maxread = read_buftop - read_bufend; nread = ano_sockread(fd, read_bufend, maxread); errno_save = ano_sockgeterr(); - if (debug >= 3) - alog("debug: buffered_read_one wanted %d, got %d", maxread, - nread); + Alog(LOG_DEBUG_3) << "buffered_read_one wanted " << maxread << ", got " << nread; if (nread <= 0) break; read_bufend += nread; @@ -169,8 +162,7 @@ static int buffered_read_one(ano_socket_t fd) read_bufend = read_netbuf; } if (read_curpos == read_bufend) { /* No more data on socket */ - if (debug >= 4) - alog("debug: buffered_read_one(%d) returning %d", fd, EOF); + Alog(LOG_DEBUG_4) << "buffered_read_one(" << fd << ") returning " << EOF; ano_sockseterr(errno_save); return EOF; } @@ -178,8 +170,7 @@ static int buffered_read_one(ano_socket_t fd) if (read_curpos == read_buftop) read_curpos = read_netbuf; total_read++; - if (debug >= 4) - alog("debug: buffered_read_one(%d) returning %d", fd, c); + Alog(LOG_DEBUG_4) << "buffered_read_one(" << fd << ") returning " << c; return static_cast<int>(c) & 0xFF; } @@ -226,9 +217,7 @@ static int flush_write_buffer(int wait) maxwrite = write_bufend - write_curpos; nwritten = ano_sockwrite(write_fd, write_curpos, maxwrite); errno_save = ano_sockgeterr(); - if (debug >= 3) - alog("debug: flush_write_buffer wanted %d, got %d", maxwrite, - nwritten); + Alog(LOG_DEBUG_3) << "flush_write_buffer wanted " << maxwrite << ", got " << nwritten; if (nwritten > 0) { write_curpos += nwritten; if (write_curpos == write_buftop) @@ -305,11 +294,8 @@ static int buffered_write(ano_socket_t fd, char *buf, int len) break; } } - - if (debug >= 4) { - alog("debug: buffered_write(%d,%p,%d) returning %d", - fd, buf, len, len - left); - } + Alog(LOG_DEBUG_4) << "buffered_write(" << fd << "," << static_cast<void*>(buf) << "," << len + << ") returning " << len - left; ano_sockseterr(errno_save); return len - left; } @@ -337,17 +323,13 @@ static int buffered_write_one(int c, ano_socket_t fd) write_fd = fd; /* Try to flush the buffer if it's full. */ - if (write_curpos == write_bufend + 1 || - (write_curpos == write_netbuf - && write_bufend == write_buftop - 1)) { + if (write_curpos == write_bufend + 1 || (write_curpos == write_netbuf && write_bufend == write_buftop - 1)) + { flush_write_buffer(1); - if (write_curpos == write_bufend + 1 || - (write_curpos == write_netbuf - && write_bufend == write_buftop - 1)) { + if (write_curpos == write_bufend + 1 || (write_curpos == write_netbuf && write_bufend == write_buftop - 1)) + { /* Write failed */ - if (debug >= 4) - alog("debug: buffered_write_one(%d) returning %d", fd, - EOF); + Alog(LOG_DEBUG_4) << "buffered_write_one(" << fd << ") returning " << EOF; return EOF; } } @@ -360,8 +342,7 @@ static int buffered_write_one(int c, ano_socket_t fd) /* Move it to the socket if we can. */ flush_write_buffer(0); - if (debug >= 4) - alog("debug: buffered_write_one(%d) returning %d", fd, c); + Alog(LOG_DEBUG_4) << "buffered_write_one(" << fd << ") returning " << c; return (int) c & 0xFF; } #endif /* 0 */ @@ -587,8 +568,9 @@ int conn(const char *host, int port, const char *lhost, int lport) memcpy(&sa.sin_addr, hp->h_addr, hp->h_length); sa.sin_family = hp->h_addrtype; #else - if (!(addr = pack_ip(host))) { - alog("conn(): `%s' is not a valid IP address", host); + if (!(addr = pack_ip(host))) + { + Alog() << "conn(): `'" << host << "' is not a valid IP address"; ano_sockseterr(SOCKERR_EINVAL); return -1; } @@ -600,13 +582,11 @@ int conn(const char *host, int port, const char *lhost, int lport) if ((sock = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) return -1; - if (setsockopt - (sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char *>(&sockopt), - sizeof(int)) < 0) - alog("debug: couldn't set SO_REUSEADDR on socket"); + if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char *>(&sockopt), sizeof(int)) < 0) + Alog() << "couldn't set SO_REUSEADDR on socket"; - if ((lhost || lport) - && bind(sock, reinterpret_cast<struct sockaddr *>(&lsa), sizeof(lsa)) < 0) { + if ((lhost || lport) && bind(sock, reinterpret_cast<struct sockaddr *>(&lsa), sizeof(lsa)) < 0) + { int errno_save = ano_sockgeterr(); ano_sockclose(sock); ano_sockseterr(errno_save); diff --git a/src/users.c b/src/users.c index c67d1a762..240a16015 100644 --- a/src/users.c +++ b/src/users.c @@ -64,7 +64,7 @@ User::User(const std::string &snick, const std::string &suid) maxusercnt = usercnt; maxusertime = time(NULL); if (Config.LogMaxUsers) - alog("user: New maximum user count: %d", maxusercnt); + Alog() << "user: New maximum user count: "<< maxusercnt; } this->isSuperAdmin = 0; /* always set SuperAdmin to 0 for new users */ @@ -80,8 +80,7 @@ void User::SetNewNick(const std::string &newnick) throw "User::SetNewNick() got a bad argument"; } - if (debug) - alog("debug: %s changed nick to %s", this->nick.c_str(), newnick.c_str()); + Alog(LOG_DEBUG) << this->nick << " changed nick to " << newnick; if (this->prev) this->prev->next = this->next; @@ -115,8 +114,7 @@ void User::SetDisplayedHost(const std::string &shost) delete [] this->vhost; this->vhost = sstrdup(shost.c_str()); - if (debug) - alog("debug: %s changed vhost to %s", this->nick.c_str(), shost.c_str()); + Alog(LOG_DEBUG) << this->nick << " changed vhost to " << shost; this->UpdateHost(); } @@ -144,8 +142,7 @@ void User::SetCloakedHost(const std::string &newhost) chost = newhost; - if (debug) - alog("debug: %s changed cloaked host to %s", this->nick.c_str(), newhost.c_str()); + Alog(LOG_DEBUG) << this->nick << " changed cloaked host to " << newhost; this->UpdateHost(); } @@ -168,8 +165,7 @@ void User::SetVIdent(const std::string &sident) { this->vident = sident; - if (debug) - alog("debug: %s changed ident to %s", this->nick.c_str(), sident.c_str()); + Alog(LOG_DEBUG) << this->nick << " changed ident to " << sident; this->UpdateHost(); } @@ -188,8 +184,7 @@ void User::SetIdent(const std::string &sident) { this->ident = sident; - if (debug) - alog("debug: %s changed real ident to %s", this->nick.c_str(), sident.c_str()); + Alog(LOG_DEBUG) << this->nick << " changed real ident to " << sident; this->UpdateHost(); } @@ -199,6 +194,13 @@ const std::string &User::GetIdent() const return this->ident; } +const std::string User::GetMask() +{ + std::stringstream buf; + buf << this->nick << "!" << this->ident << "@" << this->host; + return buf.str(); +} + void User::SetRealname(const std::string &srealname) { if (srealname.empty()) @@ -216,46 +218,34 @@ void User::SetRealname(const std::string &srealname) na->last_realname = sstrdup(srealname.c_str()); } - if (debug) - alog("debug: %s changed realname to %s", this->nick.c_str(), srealname.c_str()); + Alog(LOG_DEBUG) << this->nick << " changed realname to " << srealname; } User::~User() { char *srealname; + Alog(LOG_DEBUG_2) << "User::~User() called"; + if (Config.LogUsers) { srealname = normalizeBuffer(this->realname); - if (ircd->vhost) - { - alog("LOGUSERS: %s (%s@%s => %s) (%s) left the network (%s).", - this->nick.c_str(), this->GetIdent().c_str(), this->host, - this->GetDisplayedHost().c_str(), srealname, this->server->name); - } - else - { - alog("LOGUSERS: %s (%s@%s) (%s) left the network (%s).", - this->nick.c_str(), this->GetIdent().c_str(), this->host, - srealname, this->server->name); - } + Alog() << "LOGUSERS: " << this->GetMask() << (ircd->vhost ? " => " : " ") + << (ircd->vhost ? this->GetDisplayedHost() : "") + << " (" << srealname << ") left the network (" << this->server->name << ")."; delete [] srealname; } FOREACH_MOD(I_OnUserLogoff, OnUserLogoff(this)); - if (debug >= 2) - alog("debug: User::~User() called"); - usercnt--; if (is_oper(this)) opcnt--; - if (debug >= 2) - alog("debug: User::~User(): free user data"); + Alog(LOG_DEBUG_2) << "User::~User(): free user data"; delete [] this->host; @@ -267,8 +257,7 @@ User::~User() if (this->hostip) delete [] this->hostip; - if (debug >= 2) - alog("debug: User::~User(): remove from channels"); + Alog(LOG_DEBUG_2) << "User::~User(): remove from channels"; while (!this->chans.empty()) { @@ -278,8 +267,7 @@ User::~User() /* Cancel pending nickname enforcers, etc */ cancel_user(this); - if (debug >= 2) - alog("debug: User::~User(): delete from list"); + Alog(LOG_DEBUG_2) << "User::~User(): delete from list"; if (this->prev) this->prev->next = this->next; @@ -289,8 +277,7 @@ User::~User() if (this->next) this->next->prev = this->prev; - if (debug >= 2) - alog("debug: User::~User() done"); + Alog(LOG_DEBUG_2) << "User::~User() done"; } void User::SendMessage(const std::string &source, const char *fmt, ...) @@ -436,8 +423,7 @@ User *finduser(const std::string &nick) { User *user; - if (debug >= 3) - alog("debug: finduser(%p)", nick.c_str()); + Alog(LOG_DEBUG_3) << "finduser("<< nick << ")"; if (isdigit(nick[0]) && ircd->ts6) return find_byuid(nick); @@ -447,8 +433,7 @@ User *finduser(const std::string &nick) user = userlist[HASH(nick)]; while (user && ci_nick != user->nick) user = user->next; - if (debug >= 3) - alog("debug: finduser(%s) -> 0x%p", nick.c_str(), static_cast<void *>(user)); + Alog(LOG_DEBUG_3) << "finduser(" << nick << ") -> " << static_cast<void *>(user); FOREACH_MOD(I_OnFindUser, OnFindUser(user)); return user; } @@ -640,9 +625,7 @@ User *firstuser() current = NULL; while (next_index < 1024 && current == NULL) current = userlist[next_index++]; - if (debug) - alog("debug: firstuser() returning %s", - current ? current->nick.c_str() : "NULL (end of list)"); + Alog(LOG_DEBUG) << "firstuser() returning " << (current ? current->nick : "NULL (end of list)"); return current; } @@ -654,9 +637,7 @@ User *nextuser() while (next_index < 1024 && current == NULL) current = userlist[next_index++]; } - if (debug) - alog("debug: nextuser() returning %s", - current ? current->nick.c_str() : "NULL (end of list)"); + Alog(LOG_DEBUG) << "nextuser() returning " << (current ? current->nick : "NULL (end of list)"); return current; } @@ -686,11 +667,9 @@ User *first_uid() while (next_index_uid < 1024 && current_uid == NULL) { current_uid = userlist[next_index_uid++]; } - if (debug >= 2) { - alog("debug: first_uid() returning %s %s", - current_uid ? current_uid->nick.c_str() : "NULL (end of list)", - current_uid ? current_uid->GetUID().c_str() : ""); - } + Alog(LOG_DEBUG_2) << "first_uid() returning " + << (current_uid ? current_uid->nick : "NULL (end of list)") << " " + << (current_uid ? current_uid->GetUID() : ""); return current_uid; } @@ -702,11 +681,9 @@ User *next_uid() while (next_index_uid < 1024 && current_uid == NULL) current_uid = userlist[next_index_uid++]; } - if (debug >= 2) { - alog("debug: next_uid() returning %s %s", - current_uid ? current_uid->nick.c_str() : "NULL (end of list)", - current_uid ? current_uid->GetUID().c_str() : ""); - } + Alog(LOG_DEBUG_2) << "next_uid() returning " + << (current_uid ? current_uid->nick : "NULL (end of list)") << " " + << (current_uid ? current_uid->GetUID() : ""); return current_uid; } @@ -735,15 +712,13 @@ User *do_nick(const char *source, const char *nick, const char *username, const if (vhost) { if (!strcmp(vhost, "*")) { vhost = NULL; - if (debug) - alog("debug: new user�with no vhost in NICK command: %s", nick); + Alog(LOG_DEBUG) << "new user with no vhost in NICK command: " << nick; } } } /* This is a new user; create a User structure for it. */ - if (debug) - alog("debug: new user: %s", nick); + Alog(LOG_DEBUG) << "new user: " << nick; if (ircd->nickip) { addr.s_addr = htonl(ip); @@ -752,8 +727,8 @@ User *do_nick(const char *source, const char *nick, const char *username, const if (Config.LogUsers) { - /** - * Ugly swap routine for Flop's bug :) + /** + * Ugly swap routine for Flop's bug :) XXX **/ if (realname) { tmp = const_cast<char *>(strchr(realname, '%')); @@ -764,23 +739,14 @@ User *do_nick(const char *source, const char *nick, const char *username, const } logrealname = normalizeBuffer(realname); - /** + /** * End of ugly swap **/ - - if (ircd->nickvhost) { - if (ircd->nickip) { - alog("LOGUSERS: %s (%s@%s => %s) (%s) [%s] connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, ipbuf, server); - } else { - alog("LOGUSERS: %s (%s@%s => %s) (%s) connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, server); - } - } else { - if (ircd->nickip) { - alog("LOGUSERS: %s (%s@%s) (%s) [%s] connected to the network (%s).", nick, username, host, logrealname, ipbuf, server); - } else { - alog("LOGUSERS: %s (%s@%s) (%s) connected to the network (%s).", nick, username, host, logrealname, server); - } - } + Alog() << "LOGUSERS: " << nick << " (" << username << "@" << host + << (ircd->nickvhost && vhost ? " => " : "") + << (ircd->nickvhost && vhost ? vhost : "") << ") (" << logrealname << ") " + << (ircd->nickip ? "[" : "") << (ircd->nickip ? ipbuf : "") << (ircd->nickip ? "]" : "") + << "connected to the network (" << server << ")."; delete [] logrealname; } @@ -836,25 +802,19 @@ User *do_nick(const char *source, const char *nick, const char *username, const user = finduser(source); if (!user) { - alog("user: NICK from nonexistent nick %s", source); + Alog() << "user: NICK from nonexistent nick " << source; return NULL; } user->isSuperAdmin = 0; /* Dont let people nick change and stay SuperAdmins */ - if (debug) - alog("debug: %s changes nick to %s", source, nick); + Alog(LOG_DEBUG) << source << " changes nick to " << nick; if (Config.LogUsers) { logrealname = normalizeBuffer(user->realname); - if (ircd->vhost) { - alog("LOGUSERS: %s (%s@%s => %s) (%s) changed nick to %s (%s).", user->nick.c_str(), user->GetIdent().c_str(), user->host, user->GetDisplayedHost().c_str(), logrealname, nick, user->server->name); - } else { - alog("LOGUSERS: %s (%s@%s) (%s) changed nick to %s (%s).", - user->nick.c_str(), user->GetIdent().c_str(), user->host, logrealname, - nick, user->server->name); - } - if (logrealname) { + Alog() << "LOGUSERS: " << user->nick << " (" << user->GetIdent() << "@" << user->host + << (ircd->vhost ? " => " : "") << (ircd->vhost ? user->GetDisplayedHost() : "") << ") (" + << logrealname << ") " << "changed nick to " << nick << " (" << user->server->name << ")."; + if (logrealname) delete [] logrealname; - } } user->timestamp = ts; @@ -929,7 +889,7 @@ User *do_nick(const char *source, const char *nick, const char *username, const ntmp->last_seen = time(NULL); user->UpdateHost(); ircdproto->SetAutoIdentificationToken(user); - alog("%s: %s!%s@%s automatically identified for nick %s", Config.s_NickServ, user->nick.c_str(), user->GetIdent().c_str(), user->host, user->nick.c_str()); + Alog() << Config.s_NickServ << ": " << user->GetMask() << "automatically identified for group " << user->nc->display; } /* Bahamut sets -r on every nick changes, so we must test it even if nc_changed == 0 */ @@ -958,8 +918,7 @@ void do_umode(const char *source, int ac, const char **av) user = finduser(av[0]); if (!user) { - alog("user: MODE %s for nonexistent nick %s: %s", av[1], av[0], - merge_args(ac, av)); + Alog() << "user: MODE "<< av[1] << " for nonexistent nick "<< av[0] << ":" << merge_args(ac, av); return; } @@ -979,13 +938,10 @@ void do_quit(const char *source, int ac, const char **av) user = finduser(source); if (!user) { - alog("user: QUIT from nonexistent user %s: %s", source, - merge_args(ac, av)); + Alog() << "user: QUIT from nonexistent user " << source << ":" << merge_args(ac, av); return; } - if (debug) { - alog("debug: %s quits", source); - } + Alog(LOG_DEBUG) << source << " quits"; if ((na = findnick(user->nick)) && !na->HasFlag(NS_FORBIDDEN) && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || nick_identified(user))) { na->last_seen = time(NULL); @@ -1013,21 +969,18 @@ void do_kill(const std::string &nick, const std::string &msg) NickAlias *na; user = finduser(nick); - if (!user) { - if (debug) { - alog("debug: KILL of nonexistent nick: %s", nick.c_str()); - } + if (!user) + { + Alog(LOG_DEBUG) << "KILL of nonexistent nick: " << nick; return; } - if (debug) { - alog("debug: %s killed", nick.c_str()); - } - if ((na = findnick(user->nick)) && !na->HasFlag(NS_FORBIDDEN) && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || nick_identified(user))) { + Alog(LOG_DEBUG) << nick << " killed"; + if ((na = findnick(user->nick)) && !na->HasFlag(NS_FORBIDDEN) && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || nick_identified(user))) + { na->last_seen = time(NULL); if (na->last_quit) delete [] na->last_quit; na->last_quit = !msg.empty() ? sstrdup(msg.c_str()) : NULL; - } if (Config.LimitSessions && !is_ulined(user->server->name)) { del_session(user->host); @@ -1205,8 +1158,7 @@ void UserSetInternalModes(User *user, int ac, const char **av) if (!user || !modes) return; - if (debug) - alog("debug: Changing user modes for %s to %s", user->nick.c_str(), merge_args(ac, av)); + Alog(LOG_DEBUG) << "Changing user modes for " << user->nick << " to " << merge_args(ac, av); for (; *modes; *modes++) { |