summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bots.cpp15
-rw-r--r--src/channels.cpp72
-rw-r--r--src/chanserv.cpp16
-rw-r--r--src/commands.cpp8
-rw-r--r--src/config.cpp127
-rw-r--r--src/encrypt.cpp4
-rw-r--r--src/init.cpp157
-rw-r--r--src/language.cpp19
-rw-r--r--src/log.cpp264
-rw-r--r--src/logger.cpp399
-rw-r--r--src/mail.cpp4
-rw-r--r--src/main.cpp268
-rw-r--r--src/memoserv.cpp2
-rw-r--r--src/messages.cpp10
-rw-r--r--src/misc.cpp4
-rw-r--r--src/modes.cpp40
-rw-r--r--src/modulemanager.cpp26
-rw-r--r--src/modules.cpp22
-rw-r--r--src/nickalias.cpp2
-rw-r--r--src/nickcore.cpp2
-rw-r--r--src/nickserv.cpp8
-rw-r--r--src/process.cpp24
-rw-r--r--src/regchannel.cpp10
-rw-r--r--src/send.cpp8
-rw-r--r--src/servers.cpp30
-rw-r--r--src/sessions.cpp12
-rw-r--r--src/sockets.cpp2
-rw-r--r--src/users.cpp110
28 files changed, 903 insertions, 762 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index d63f6787f..e6124e135 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -20,16 +20,15 @@ BotInfo *MemoServ = NULL;
BotInfo *NickServ = NULL;
BotInfo *OperServ = NULL;
-BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal) : User(nnick, ts6_uid_retrieve())
+BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal) : User(nnick, nuser, nhost, ts6_uid_retrieve())
{
- this->ident = nuser;
- this->host = nhost;
this->realname = nreal;
this->server = Me;
this->chancount = 0;
this->lastmsg = this->created = time(NULL);
+ this->SetFlag(BI_CORE);
if (!Config->s_ChanServ.empty() && nnick.equals_ci(Config->s_ChanServ))
ChanServ = this;
else if (!Config->s_BotServ.empty() && nnick.equals_ci(Config->s_BotServ))
@@ -44,6 +43,8 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
NickServ = this;
else if (!Config->s_GlobalNoticer.empty() && nnick.equals_ci(Config->s_GlobalNoticer))
Global = this;
+ else
+ this->UnsetFlag(BI_CORE);
BotListByNick[this->nick] = this;
if (!this->uid.empty())
@@ -168,16 +169,16 @@ void BotInfo::Join(Channel *c, bool update_ts)
c->JoinUser(this);
ChannelContainer *cc = this->FindChannel(c);
- for (std::list<ChannelModeStatus *>::iterator it = BotModes.begin(), it_end = BotModes.end(); it != it_end; ++it)
+ for (int i = 0; i < Config->BotModeList.size(); ++i)
{
if (!update_ts)
{
- c->SetMode(this, *it, this->nick, false);
+ c->SetMode(this, Config->BotModeList[i], this->nick, false);
}
else
{
- cc->Status->SetFlag((*it)->Name);
- c->SetModeInternal(*it, this->nick, false);
+ cc->Status->SetFlag(Config->BotModeList[i]->Name);
+ c->SetModeInternal(Config->BotModeList[i], this->nick, false);
}
}
if (!update_ts)
diff --git a/src/channels.cpp b/src/channels.cpp
index aa2e0affc..506dbfc7d 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -37,6 +37,8 @@ Channel::Channel(const Anope::string &name, time_t ts)
this->ci = cs_findchan(this->name);
if (this->ci)
this->ci->c = this;
+
+ Log(NULL, this, "create");
FOREACH_MOD(I_OnChannelCreate, OnChannelCreate(this));
}
@@ -49,7 +51,7 @@ Channel::~Channel()
FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
- Alog(LOG_DEBUG) << "Deleting channel " << this->name;
+ Log(NULL, this, "destroy");
for (bd = this->bd; bd; bd = next)
{
@@ -114,7 +116,7 @@ void Channel::Sync()
void Channel::JoinUser(User *user)
{
- Alog(LOG_DEBUG) << user->nick << " joins " << this->name;
+ Log(user, this, "join");
ChannelStatus *Status = new ChannelStatus();
ChannelContainer *cc = new ChannelContainer(this);
@@ -128,7 +130,7 @@ void Channel::JoinUser(User *user)
bool update_ts = false;
if (this->ci && this->ci->HasFlag(CI_PERSIST) && this->creation_time > this->ci->time_registered)
{
- Alog(LOG_DEBUG) << "Changing TS of " << this->name << " from " << this->creation_time << " to " << this->ci->time_registered;
+ Log(LOG_DEBUG) << "Changing TS of " << this->name << " from " << this->creation_time << " to " << this->ci->time_registered;
this->creation_time = this->ci->time_registered;
update_ts = true;
}
@@ -188,13 +190,13 @@ void Channel::DeleteUser(User *user)
if (this->ci)
update_cs_lastseen(user, this->ci);
- Alog(LOG_DEBUG) << user->nick << " leaves " << this->name;
+ Log(user, this, "leaves");
CUserList::iterator cit, cit_end = this->users.end();
for (cit = this->users.begin(); (*cit)->user != user && cit != cit_end; ++cit);
if (cit == cit_end)
{
- Alog(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant user " << user->nick << " from channel " << this->name;
+ Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant user " << user->nick << " from channel " << this->name;
return;
}
@@ -206,7 +208,7 @@ void Channel::DeleteUser(User *user)
for (uit = user->chans.begin(); (*uit)->chan != this && uit != uit_end; ++uit);
if (uit == uit_end)
{
- Alog(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant channel " << this->name << " from " << user->nick << "'s channel list";
+ Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant channel " << this->name << " from " << user->nick << "'s channel list";
return;
}
@@ -310,7 +312,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string &param, bool
{
if (param.empty())
{
- Alog() << "Channel::SetModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name;
+ Log() << "Channel::SetModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name;
return;
}
@@ -321,11 +323,11 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string &param, bool
if (!u)
{
- Alog(LOG_DEBUG) << "MODE " << this->name << " +" << cm->ModeChar << " for nonexistant user " << param;
+ Log() << "MODE " << this->name << " +" << cm->ModeChar << " for nonexistant user " << param;
return;
}
- Alog(LOG_DEBUG) << "Setting +" << cm->ModeChar << " on " << this->name << " for " << u->nick;
+ Log(LOG_DEBUG) << "Setting +" << cm->ModeChar << " on " << this->name << " for " << u->nick;
/* Set the status on the user */
ChannelContainer *cc = u->FindChannel(this);
@@ -342,7 +344,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string &param, bool
{
if (param.empty())
{
- Alog() << "Channel::SetModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name;
+ Log() << "Channel::SetModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name;
return;
}
@@ -357,7 +359,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string &param, bool
{
if (cm->Type != MODE_PARAM)
{
- Alog() << "Channel::SetModeInternal() mode " << cm->ModeChar << " for " << this->name << " with a paramater, but its not a param mode";
+ Log() << "Channel::SetModeInternal() mode " << cm->ModeChar << " for " << this->name << " with a paramater, but its not a param mode";
return;
}
@@ -437,7 +439,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string &param, bo
{
if (param.empty())
{
- Alog() << "Channel::RemoveModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name;
+ Log() << "Channel::RemoveModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name;
return;
}
@@ -449,17 +451,17 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string &param, bo
/* Reset modes on bots if we're supposed to */
if (bi)
{
- if (std::find(BotModes.begin(), BotModes.end(), cm) != BotModes.end())
+ if (std::find(Config->BotModeList.begin(), Config->BotModeList.end(), cm) != Config->BotModeList.end())
this->SetMode(bi, cm, bi->nick);
}
if (!u)
{
- Alog() << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->ModeChar << " for nonexistant user " << param;
+ Log() << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->ModeChar << " for nonexistant user " << param;
return;
}
- Alog(LOG_DEBUG) << "Setting -" << cm->ModeChar << " on " << this->name << " for " << u->nick;
+ Log(LOG_DEBUG) << "Setting -" << cm->ModeChar << " on " << this->name << " for " << u->nick;
/* Remove the status on the user */
ChannelContainer *cc = u->FindChannel(this);
@@ -473,7 +475,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string &param, bo
{
if (param.empty())
{
- Alog() << "Channel::RemoveModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name;
+ Log() << "Channel::RemoveModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name;
return;
}
@@ -904,11 +906,11 @@ void ChanSetInternalModes(Channel *c, int ac, const char **av)
c->RemoveModeInternal(cm, av[j]);
}
else
- Alog() << "warning: ChanSetInternalModes() recieved more modes requiring params than params, modes: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j;
+ Log() << "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: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j << " k: " << k;
+ Log() << "warning: ChanSetInternalModes() recieved more params than modes requiring them, modes: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j << " k: " << k;
}
/** Kick a user from a channel internally
@@ -924,11 +926,11 @@ void Channel::KickInternal(const Anope::string &source, const Anope::string &nic
User *user = bi ? bi : finduser(nick);
if (!user)
{
- Alog(LOG_DEBUG) << "Channel::KickInternal got a nonexistent user " << nick << " on " << this->name << ": " << reason;
+ Log() << "Channel::KickInternal got a nonexistent user " << nick << " on " << this->name << ": " << reason;
return;
}
- Alog(LOG_DEBUG) << "Channel::KickInternal kicking " << user->nick << " from " << this->name;
+ Log(user, this, "kick") << "by " << source << " (" << reason << ")";
Anope::string chname = this->name;
@@ -938,7 +940,7 @@ void Channel::KickInternal(const Anope::string &source, const Anope::string &nic
this->DeleteUser(user);
}
else
- Alog(LOG_DEBUG) << "Channel::KickInternal got kick for user " << user->nick << " who isn't on channel " << this->name << " ?";
+ Log() << "Channel::KickInternal got kick for user " << user->nick << " who isn't on channel " << this->name << " ?";
/* Bots get rejoined */
if (bi)
@@ -1113,7 +1115,7 @@ void do_join(const Anope::string &source, int ac, const char **av)
user = finduser(source);
if (!user)
{
- Alog(LOG_DEBUG) << "JOIN from nonexistent user " << source << ": " << merge_args(ac, av);
+ Log() << "JOIN from nonexistent user " << source << ": " << merge_args(ac, av);
return;
}
@@ -1150,7 +1152,7 @@ void do_join(const Anope::string &source, int ac, const char **av)
/* Their time is older, we lose */
if (chan->creation_time > ts)
{
- Alog(LOG_DEBUG) << "Recieved an older TS " << chan->name << " in JOIN, changing from " << chan->creation_time << " to " << ts;
+ Log(LOG_DEBUG) << "Recieved an older TS " << chan->name << " in JOIN, changing from " << chan->creation_time << " to " << ts;
chan->creation_time = ts;
chan->Reset();
@@ -1188,7 +1190,7 @@ void do_kick(const Anope::string &source, int ac, const char **av)
Channel *c = findchan(av[0]);
if (!c)
{
- Alog(LOG_DEBUG) << "Recieved kick for nonexistant channel " << av[0];
+ Log() << "Recieved kick for nonexistant channel " << av[0];
return;
}
@@ -1210,7 +1212,7 @@ void do_part(const Anope::string &source, int ac, const char **av)
User *user = finduser(source);
if (!user)
{
- Alog(LOG_DEBUG) << "PART from nonexistent user " << source << ": " << merge_args(ac, av);
+ Log() << "PART from nonexistent user " << source << ": " << merge_args(ac, av);
return;
}
@@ -1221,17 +1223,17 @@ void do_part(const Anope::string &source, int ac, const char **av)
Channel *c = findchan(buf);
if (!c)
- Alog(LOG_DEBUG) << "Recieved PART from " << user->nick << " for nonexistant channel " << buf;
-
- if (user->FindChannel(c))
+ Log() << "Recieved PART from " << user->nick << " for nonexistant channel " << buf;
+ else if (user->FindChannel(c))
{
+ Log(user, c, "part") << "Reason: " << (av[1] ? av[1] : "No reason");
FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c));
Anope::string ChannelName = c->name;
c->DeleteUser(user);
FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(ChannelName), ChannelName, av[1] ? av[1] : ""));
}
else
- Alog(LOG_DEBUG) << "Recieved PART from " << user->nick << " for " << c->name << ", but " << user->nick << " isn't in " << c->name << "?";
+ Log() << "Recieved PART from " << user->nick << " for " << c->name << ", but " << user->nick << " isn't in " << c->name << "?";
}
}
@@ -1264,7 +1266,7 @@ void do_cmode(const Anope::string &source, int ac, const char **av)
++av;
}
else
- Alog() << "TSMODE enabled but MODE has no valid TS";
+ Log() << "TSMODE enabled but MODE has no valid TS";
}
/* :42XAAAAAO TMODE 1106409026 #ircops +b *!*@*.aol.com */
@@ -1281,7 +1283,7 @@ void do_cmode(const Anope::string &source, int ac, const char **av)
{
ci = cs_findchan(av[0]);
if (!ci || ci->HasFlag(CI_FORBIDDEN))
- Alog(LOG_DEBUG) << "MODE " << merge_args(ac - 1, av + 1) << " for nonexistant channel " << av[0];
+ Log(LOG_DEBUG) << "MODE " << merge_args(ac - 1, av + 1) << " for nonexistant channel " << av[0];
}
return;
}
@@ -1298,6 +1300,10 @@ void do_cmode(const Anope::string &source, int ac, const char **av)
--ac;
++av;
+
+ User *u = finduser(source);
+ if (u)
+ Log(u, c, "mode") << merge_args(ac, av);
ChanSetInternalModes(c, ac, av);
}
@@ -1313,7 +1319,7 @@ void do_topic(const Anope::string &source, int ac, const char **av)
if (!c)
{
- Alog(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
+ Log() << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
return;
}
@@ -1380,7 +1386,7 @@ void chan_set_correct_modes(User *user, Channel *c, int give_modes)
if (ci->HasFlag(CI_FORBIDDEN) || c->name[0] == '+')
return;
- Alog(LOG_DEBUG) << "Setting correct user modes for " << user->nick << " on " << c->name << " (" << (give_modes ? "" : "not ") << "giving modes)";
+ Log(LOG_DEBUG) << "Setting correct user modes for " << user->nick << " on " << c->name << " (" << (give_modes ? "" : "not ") << "giving modes)";
if (give_modes && !get_ignore(user->nick) && (!user->Account() || user->Account()->HasFlag(NI_AUTOOP)))
{
diff --git a/src/chanserv.cpp b/src/chanserv.cpp
index c80de4c75..b6df9d8cd 100644
--- a/src/chanserv.cpp
+++ b/src/chanserv.cpp
@@ -252,7 +252,7 @@ void check_modes(Channel *c)
if (!c)
{
- Alog(LOG_DEBUG) << "check_modes called with NULL values";
+ Log() << "check_modes called with NULL values";
return;
}
@@ -263,7 +263,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() << Config->s_ChanServ << ": Bouncy modes on channel " << c->name;
+ Log() << "Bouncy modes on channel " << c->name;
c->bouncy_modes = 1;
return;
}
@@ -497,7 +497,7 @@ int check_topiclock(Channel *c, time_t topic_time)
if (!c)
{
- Alog(LOG_DEBUG) << "check_topiclock called with NULL values";
+ Log() << "check_topiclock called with NULL values";
return 0;
}
@@ -572,7 +572,7 @@ void expire_chans()
continue;
Anope::string chname = ci->name;
- Alog() << "Expiring channel " << ci->name << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << " )";
+ Log(LOG_NORMAL, "chanserv/expire") << "Expiring channel " << ci->name << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << " )";
delete ci;
FOREACH_MOD(I_OnChanExpire, OnChanExpire(chname));
}
@@ -599,13 +599,13 @@ void cs_remove_nick(const NickCore *nc)
NickCore *nc2 = ci->successor;
if (!nc2->IsServicesOper() && Config->CSMaxReg && nc2->channelcount >= Config->CSMaxReg)
{
- Alog() << Config->s_ChanServ << ": Successor (" << nc2->display << " ) of " << ci->name << " owns too many channels, deleting channel",
+ Log(LOG_NORMAL, "chanserv/expire") << "Successor (" << nc2->display << " ) of " << ci->name << " owns too many channels, deleting channel",
delete ci;
continue;
}
else
{
- Alog() << Config->s_ChanServ << ": Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to successor " << nc2->display;
+ Log(LOG_NORMAL, "chanserv/expire") << "Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to successor " << nc2->display;
ci->founder = nc2;
ci->successor = NULL;
++nc2->channelcount;
@@ -613,7 +613,7 @@ void cs_remove_nick(const NickCore *nc)
}
else
{
- Alog() << Config->s_ChanServ << ": Deleting channel " << ci->name << "owned by deleted nick " << nc->display;
+ Log(LOG_NORMAL, "chanserv/expire") << "Deleting channel " << ci->name << "owned by deleted nick " << nc->display;
if (ModeManager::FindChannelModeByName(CMODE_REGISTERED))
{
@@ -712,7 +712,7 @@ void reset_levels(ChannelInfo *ci)
if (!ci)
{
- Alog(LOG_DEBUG) << "reset_levels() called with NULL values";
+ Log() << "reset_levels() called with NULL values";
return;
}
diff --git a/src/commands.cpp b/src/commands.cpp
index 26ca76e65..bbf2a5233 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -58,7 +58,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command,
if (!c->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->IsIdentified())
{
notice_lang(bi->nick, u, NICK_IDENTIFY_REQUIRED, Config->s_NickServ.c_str());
- Alog() << "Access denied for unregistered user " << u->nick << " with service " << bi->nick << " and command " << command;
+ Log(LOG_COMMAND, "denied", bi) << "Access denied for unregistered user " << u->GetMask() << " with command " << command;
return;
}
@@ -103,13 +103,13 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command,
if (ci->HasFlag(CI_FORBIDDEN) && !c->HasFlag(CFLAG_ALLOW_FORBIDDEN))
{
notice_lang(bi->nick, u, CHAN_X_FORBIDDEN, ci->name.c_str());
- Alog() << "Access denied for user " << u->nick << " with service " << bi->nick << " and command " << command << " because of FORBIDDEN channel " << ci->name;
+ Log(LOG_COMMAND, "denied", bi) << "Access denied for user " << u->GetMask() << " with command " << command << " because of FORBIDDEN channel " << ci->name;
return;
}
else if (ci->HasFlag(CI_SUSPENDED) && !c->HasFlag(CFLAG_ALLOW_SUSPENDED))
{
notice_lang(bi->nick, u, CHAN_X_FORBIDDEN, ci->name.c_str());
- Alog() << "Access denied for user " << u->nick << " with service " << bi->nick <<" and command " << command << " because of SUSPENDED channel " << ci->name;
+ Log(LOG_COMMAND, "denied", bi) << "Access denied for user " << u->GetMask() << " with command " << command << " because of SUSPENDED channel " << ci->name;
return;
}
}
@@ -131,7 +131,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command,
if (!c->permission.empty() && !u->Account()->HasCommand(c->permission))
{
notice_lang(bi->nick, u, ACCESS_DENIED);
- Alog() << "Access denied for user " << u->nick << " with service " << bi->nick << " and command " << command;
+ Log(LOG_COMMAND, "denied", bi) << "Access denied for user " << u->GetMask() << " with command " << command;
return;
}
diff --git a/src/config.cpp b/src/config.cpp
index 0dfc9702e..48563b0c5 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -82,7 +82,7 @@ ServerConfig::ServerConfig() : errstr(""), config_data()
else if (option.equals_ci("msg"))
{
if (!this->UsePrivmsg)
- Alog() << "msg in <nickserv:defaults> can only be used when UsePrivmsg is set";
+ Log() << "msg in <nickserv:defaults> can only be used when UsePrivmsg is set";
else
this->NSDefFlags.SetFlag(NI_MSG);
}
@@ -262,7 +262,7 @@ ServerConfig::ServerConfig() : errstr(""), config_data()
/* Check the user keys */
if (this->UserKey1 == this->UserKey2 || this->UserKey1 == this->UserKey3 || this->UserKey3 == this->UserKey2)
- Alog() << "Every UserKey must be different. It's for YOUR safety! Remember that!";
+ Log() << "Every UserKey must be different. It's for YOUR safety! Remember that!";
/**
* Check all DEFCON dependiencies...
@@ -349,10 +349,6 @@ ServerConfig::ServerConfig() : errstr(""), config_data()
}
SetDefaultMLock(this);
-
- /* Disable the log channel if its defined in the conf, but not enabled */
- if (this->LogChannel.empty() && LogChan)
- LogChan = false;
}
bool ServerConfig::CheckOnce(const Anope::string &tag)
@@ -614,13 +610,13 @@ bool ValidateNickLen(ServerConfig *, const Anope::string &, const Anope::string
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";
+ Log() << "You have not defined the <networkinfo:nicklen> directive. It is strongly";
+ Log() << "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 31";
+ Log() << "<networkinfo:nicklen> has an invalid value; setting to 31";
data.Set(31);
}
return true;
@@ -645,7 +641,7 @@ bool ValidateGlobalOnCycle(ServerConfig *config, const Anope::string &tag, const
{
if (data.GetValue().empty())
{
- Alog() << "<" << tag << ":" << value << "> was undefined, disabling <options:globaloncycle>";
+ Log() << "<" << tag << ":" << value << "> was undefined, disabling <options:globaloncycle>";
config->GlobalOnCycle = false;
}
}
@@ -733,7 +729,7 @@ static bool DoOperType(ServerConfig *config, const Anope::string &, const Anope:
{
if ((*it)->GetName().equals_ci(tok))
{
- Alog() << "Inheriting commands and privs from " << (*it)->GetName() << " to " << ot->GetName();
+ Log() << "Inheriting commands and privs from " << (*it)->GetName() << " to " << ot->GetName();
ot->Inherits(*it);
break;
}
@@ -797,7 +793,7 @@ static bool DoneOpers(ServerConfig *config, const Anope::string &)
OperType *ot = *tit;
if (ot->GetName().equals_ci(type))
{
- Alog() << "Tied oper " << na->nc->display << " to type " << type;
+ Log() << "Tied oper " << na->nc->display << " to type " << type;
na->nc->ot = ot;
}
}
@@ -833,6 +829,91 @@ bool DoneModules(ServerConfig *, const Anope::string &)
return true;
}
+bool InitLogs(ServerConfig *config, const Anope::string &)
+{
+ for (unsigned i = 0; i < config->LogInfos.size(); ++i)
+ {
+ LogInfo *l = config->LogInfos[i];
+
+ for (std::list<Anope::string>::const_iterator sit = l->Targets.begin(), sit_end = l->Targets.end(); sit != sit_end; ++sit)
+ {
+ const Anope::string &target = *sit;
+
+ if (target[0] == '#')
+ {
+ Channel *c = findchan(target);
+ if (c && c->HasFlag(CH_LOGCHAN))
+ {
+ for (CUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit)
+ {
+ UserContainer *uc = *cit;
+ BotInfo *bi = findbot(uc->user->nick);
+
+ if (bi && bi->HasFlag(BI_CORE))
+ {
+ bi->Part(c, "Reloading");
+ }
+ }
+
+ c->UnsetFlag(CH_PERSIST);
+ c->UnsetFlag(CH_LOGCHAN);
+ if (c->users.empty())
+ delete c;
+ }
+ }
+ }
+
+ delete config->LogInfos[i];
+ }
+ config->LogInfos.clear();
+
+ return true;
+}
+
+bool DoLogs(ServerConfig *config, const Anope::string &, const Anope::string *, ValueList &values, int *)
+{
+ //{"target", "source", "logage", "admin", "override", "commands", "servers", "channels", "users", "normal", "rawio", "debug"},
+ Anope::string targets = values[0].GetValue();
+ ValueItem vi(targets);
+ if (!ValidateNotEmpty(config, "log", "target", vi))
+ throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information.");
+
+ Anope::string source = values[1].GetValue();
+ int logage = values[2].GetInteger();
+ Anope::string admin = values[3].GetValue();
+ Anope::string override = values[4].GetValue();
+ Anope::string commands = values[5].GetValue();
+ Anope::string servers = values[6].GetValue();
+ Anope::string channels = values[7].GetValue();
+ Anope::string users = values[8].GetValue();
+ bool normal = values[9].GetBool();
+ bool rawio = values[10].GetBool();
+ bool ldebug = values[11].GetBool();
+
+ LogInfo *l = new LogInfo(logage, normal, rawio, ldebug);
+ l->Targets = BuildStringList(targets);
+ l->Sources = BuildStringList(source);
+ l->Admin = BuildStringList(admin);
+ l->Override = BuildStringList(override);
+ l->Commands = BuildStringList(commands);
+ l->Servers = BuildStringList(servers);
+ l->Channels = BuildStringList(channels);
+ l->Users = BuildStringList(users);
+
+ config->LogInfos.push_back(l);
+
+ return true;
+}
+
+bool DoneLogs(ServerConfig *config, const Anope::string &)
+{
+ InitLogChannels(config);
+
+ Log() << "Loaded " << config->LogInfos.size() << " log blocks";
+
+ return true;
+}
+
void ServerConfig::Read()
{
errstr.clear();
@@ -902,8 +983,6 @@ void ServerConfig::Read()
{"serverinfo", "hostname", "", new ValueContainerString(&this->ServiceHost), DT_STRING | DT_NORELOAD, ValidateNotEmpty},
{"serverinfo", "pid", "services.pid", new ValueContainerString(&this->PIDFilename), DT_STRING | DT_NORELOAD, ValidateNotEmpty},
{"serverinfo", "motd", "services.motd", new ValueContainerString(&this->MOTDFilename), DT_STRING, ValidateNotEmpty},
- {"networkinfo", "logchannel", "", new ValueContainerString(&this->LogChannel), DT_STRING, NoValidation},
- {"networkinfo", "logbot", "no", new ValueContainerBool(&this->LogBot), DT_BOOLEAN, NoValidation},
{"networkinfo", "networkname", "", new ValueContainerString(&this->NetworkName), DT_STRING, ValidateNotEmpty},
{"networkinfo", "nicklen", "0", new ValueContainerUInt(&this->NickLen), DT_UINTEGER | DT_NORELOAD, ValidateNickLen},
{"networkinfo", "userlen", "10", new ValueContainerUInt(&this->UserLen), DT_UINTEGER | DT_NORELOAD, NoValidation},
@@ -930,7 +1009,6 @@ void ServerConfig::Read()
{"options", "useprivmsg", "no", new ValueContainerBool(&this->UsePrivmsg), DT_BOOLEAN, NoValidation},
{"options", "usestrictprivmsg", "no", new ValueContainerBool(&this->UseStrictPrivMsg), DT_BOOLEAN, NoValidation},
{"options", "dumpcore", "yes", new ValueContainerBool(&this->DumpCore), DT_BOOLEAN | DT_NORELOAD, NoValidation},
- {"options", "logusers", "no", new ValueContainerBool(&this->LogUsers), DT_BOOLEAN, NoValidation},
{"options", "hidestatso", "no", new ValueContainerBool(&this->HideStatsO), DT_BOOLEAN, NoValidation},
{"options", "globaloncycle", "no", new ValueContainerBool(&this->GlobalOnCycle), DT_BOOLEAN, NoValidation},
{"options", "globaloncycledown", "", new ValueContainerString(&this->GlobalOnCycleMessage), DT_STRING, ValidateGlobalOnCycle},
@@ -940,7 +1018,6 @@ void ServerConfig::Read()
{"options", "restrictopernicks", "no", new ValueContainerBool(&this->RestrictOperNicks), DT_BOOLEAN, NoValidation},
{"options", "newscount", "3", new ValueContainerUInt(&this->NewsCount), DT_UINTEGER, NoValidation},
{"options", "ulineservers", "", new ValueContainerString(&UlineServers), DT_STRING, NoValidation},
- {"options", "enablelogchannel", "no", new ValueContainerBool(&LogChan), DT_BOOLEAN, NoValidation},
{"options", "mlock", "+nrt", new ValueContainerString(&this->MLock), DT_STRING, NoValidation},
{"options", "botmodes", "", new ValueContainerString(&this->BotModes), DT_STRING, NoValidation},
{"options", "maxretries", "10", new ValueContainerUInt(&this->MaxRetries), DT_UINTEGER, NoValidation},
@@ -1017,7 +1094,6 @@ void ServerConfig::Read()
{"operserv", "globaldescription", "Global Noticer", new ValueContainerString(&this->desc_GlobalNoticer), DT_STRING | DT_NORELOAD, ValidateNotEmpty},
{"operserv", "modules", "", new ValueContainerString(&OperCoreModules), DT_STRING, NoValidation},
{"operserv", "superadmin", "no", new ValueContainerBool(&this->SuperAdmin), DT_BOOLEAN, NoValidation},
- {"operserv", "logmaxusers", "no", new ValueContainerBool(&this->LogMaxUsers), DT_BOOLEAN, NoValidation},
{"operserv", "autokillexpiry", "0", new ValueContainerTime(&this->AutokillExpiry), DT_TIME, ValidateNotZero},
{"operserv", "chankillexpiry", "0", new ValueContainerTime(&this->ChankillExpiry), DT_TIME, ValidateNotZero},
{"operserv", "snlineexpiry", "0", new ValueContainerTime(&this->SNLineExpiry), DT_TIME, ValidateNotZero},
@@ -1067,6 +1143,11 @@ void ServerConfig::Read()
{"", ""},
{DT_CHARPTR},
InitModules, DoModule, DoneModules},
+ {"log",
+ {"target", "source", "logage", "admin", "override", "commands", "servers", "channels", "users", "normal", "rawio", "debug", ""},
+ {"", "", "7", "", "", "", "", "", "", "", "no", "no", ""},
+ {DT_STRING, DT_STRING, DT_INTEGER, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_BOOLEAN, DT_BOOLEAN, DT_BOOLEAN},
+ InitLogs, DoLogs, DoneLogs},
{"opertype",
{"name", "inherits", "commands", "privs", ""},
{"", "", "", "", ""},
@@ -1339,10 +1420,10 @@ void ServerConfig::Read()
}
throw ConfigException(ce);
}
- Alog(LOG_DEBUG) << "End config";
+ Log(LOG_DEBUG) << "End config";
for (int Index = 0; !Once[Index].empty(); ++Index)
CheckOnce(Once[Index]);
- Alog() << "Done reading configuration file.";
+ Log() << "Done reading configuration file.";
}
bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filename)
@@ -1358,7 +1439,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam
errstr << "File " << filename << " could not be opened." << std::endl;
return false;
}
- Alog(LOG