mirror of
https://github.com/anope/anope.git
synced 2026-06-26 04:06:41 +02:00
Added a new logging system
This commit is contained in:
+13
-63
@@ -18,14 +18,14 @@ class CommandOSSet : public Command
|
||||
private:
|
||||
CommandReturn DoList(User *u)
|
||||
{
|
||||
Log(LOG_ADMIN, u, this);
|
||||
|
||||
int index;
|
||||
|
||||
index = allow_ignore ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF;
|
||||
notice_lang(Config->s_OperServ, u, index, "IGNORE");
|
||||
index = readonly ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF;
|
||||
notice_lang(Config->s_OperServ, u, index, "READONLY");
|
||||
index = LogChan ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF;
|
||||
notice_lang(Config->s_OperServ, u, index, "LOGCHAN");
|
||||
index = debug ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF;
|
||||
notice_lang(Config->s_OperServ, u, index, "DEBUG");
|
||||
index = noexpire ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF;
|
||||
@@ -46,11 +46,13 @@ class CommandOSSet : public Command
|
||||
|
||||
if (setting.equals_ci("ON"))
|
||||
{
|
||||
Log(LOG_ADMIN, u, this) << "IGNORE ON";
|
||||
allow_ignore = 1;
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_IGNORE_ON);
|
||||
}
|
||||
else if (setting.equals_ci("OFF"))
|
||||
{
|
||||
Log(LOG_ADMIN, u, this) << "IGNORE OFF";
|
||||
allow_ignore = 0;
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_IGNORE_OFF);
|
||||
}
|
||||
@@ -73,15 +75,13 @@ class CommandOSSet : public Command
|
||||
if (setting.equals_ci("ON"))
|
||||
{
|
||||
readonly = true;
|
||||
Alog() << "Read-only mode activated";
|
||||
close_log();
|
||||
Log(LOG_ADMIN, u, this) << "READONLY ON";
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_READONLY_ON);
|
||||
}
|
||||
else if (setting.equals_ci("OFF"))
|
||||
{
|
||||
readonly = false;
|
||||
open_log();
|
||||
Alog() << "Read-only mode deactivated";
|
||||
Log(LOG_ADMIN, u, this) << "READONLY OFF";
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_READONLY_OFF);
|
||||
}
|
||||
else
|
||||
@@ -90,52 +90,6 @@ class CommandOSSet : public Command
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
CommandReturn DoSetLogChan(User *u, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Anope::string setting = params.size() > 1 ? params[1] : "";
|
||||
Channel *c;
|
||||
|
||||
if (setting.empty())
|
||||
{
|
||||
this->OnSyntaxError(u, "LOGCHAN");
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
/* Unlike the other SET commands where only stricmp is necessary,
|
||||
* we also have to ensure that Config->LogChannel is defined or we can't
|
||||
* send to it.
|
||||
*
|
||||
* -jester
|
||||
*/
|
||||
if (!Config->LogChannel.empty() && setting.equals_ci("ON"))
|
||||
{
|
||||
if (ircd->join2msg)
|
||||
{
|
||||
c = findchan(Config->LogChannel);
|
||||
if (c)
|
||||
Global->Join(c);
|
||||
else
|
||||
Global->Join(Config->LogChannel);
|
||||
}
|
||||
LogChan = true;
|
||||
Alog() << "Now sending log messages to " << Config->LogChannel;
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_LOGCHAN_ON, Config->LogChannel.c_str());
|
||||
}
|
||||
else if (!Config->LogChannel.empty() && setting.equals_ci("OFF"))
|
||||
{
|
||||
Alog() << "No longer sending log messages to a channel";
|
||||
c = findchan(Config->LogChannel);
|
||||
if (ircd->join2msg && c)
|
||||
Global->Part(c);
|
||||
LogChan = false;
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_LOGCHAN_OFF);
|
||||
}
|
||||
else
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_LOGCHAN_ERROR);
|
||||
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
CommandReturn DoSetSuperAdmin(User *u, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Anope::string setting = params.size() > 1 ? params[1] : "";
|
||||
@@ -157,14 +111,14 @@ class CommandOSSet : public Command
|
||||
{
|
||||
u->isSuperAdmin = 1;
|
||||
notice_lang(Config->s_OperServ, u, OPER_SUPER_ADMIN_ON);
|
||||
Alog() << Config->s_OperServ << ": " << u->nick << " is a SuperAdmin";
|
||||
Log(LOG_ADMIN, u, this) << "SUPERADMIN ON";
|
||||
ircdproto->SendGlobops(OperServ, getstring(OPER_SUPER_ADMIN_WALL_ON), u->nick.c_str());
|
||||
}
|
||||
else if (setting.equals_ci("OFF"))
|
||||
{
|
||||
u->isSuperAdmin = 0;
|
||||
notice_lang(Config->s_OperServ, u, OPER_SUPER_ADMIN_OFF);
|
||||
Alog() << Config->s_OperServ << ": " << u->nick << " is no longer a SuperAdmin";
|
||||
Log(LOG_ADMIN, u, this) << "SUPERADMIN OFF";
|
||||
ircdproto->SendGlobops(OperServ, getstring(OPER_SUPER_ADMIN_WALL_OFF), u->nick.c_str());
|
||||
}
|
||||
else
|
||||
@@ -186,19 +140,19 @@ class CommandOSSet : public Command
|
||||
if (setting.equals_ci("ON"))
|
||||
{
|
||||
debug = 1;
|
||||
Alog() << "Debug mode activated";
|
||||
Log(LOG_ADMIN, u, this) << "DEBUG ON";
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_DEBUG_ON);
|
||||
}
|
||||
else if (setting.equals_ci("OFF") || (setting[0] == '0' && setting.is_number_only() && !convertTo<int>(setting)))
|
||||
{
|
||||
Alog() << "Debug mode deactivated";
|
||||
Log(LOG_ADMIN, u, this) << "DEBUG OFF";
|
||||
debug = 0;
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_DEBUG_OFF);
|
||||
}
|
||||
else if (setting.is_number_only() && convertTo<int>(setting) > 0)
|
||||
{
|
||||
debug = convertTo<int>(setting);
|
||||
Alog() << "Debug mode activated (level " << debug << ")";
|
||||
Log(LOG_ADMIN, u, this) << "DEBUG " << debug;
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_DEBUG_LEVEL, debug);
|
||||
}
|
||||
else
|
||||
@@ -220,13 +174,13 @@ class CommandOSSet : public Command
|
||||
if (setting.equals_ci("ON"))
|
||||
{
|
||||
noexpire = true;
|
||||
Alog() << "No expire mode activated";
|
||||
Log(LOG_ADMIN, u, this) << "NOEXPIRE ON";
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_NOEXPIRE_ON);
|
||||
}
|
||||
else if (setting.equals_ci("OFF"))
|
||||
{
|
||||
noexpire = false;
|
||||
Alog() << "No expire mode deactivated";
|
||||
Log(LOG_ADMIN, u, this) << "NOEXPIRE OFF";
|
||||
notice_lang(Config->s_OperServ, u, OPER_SET_NOEXPIRE_OFF);
|
||||
}
|
||||
else
|
||||
@@ -249,8 +203,6 @@ class CommandOSSet : public Command
|
||||
return this->DoSetIgnore(u, params);
|
||||
else if (option.equals_ci("READONLY"))
|
||||
return this->DoSetReadOnly(u, params);
|
||||
else if (option.equals_ci("LOGCHAN"))
|
||||
return this->DoSetLogChan(u, params);
|
||||
else if (option.equals_ci("SUPERADMIN"))
|
||||
return this->DoSetSuperAdmin(u, params);
|
||||
else if (option.equals_ci("DEBUG"))
|
||||
@@ -270,8 +222,6 @@ class CommandOSSet : public Command
|
||||
notice_help(Config->s_OperServ, u, OPER_HELP_SET_LIST);
|
||||
else if (subcommand.equals_ci("READONLY"))
|
||||
notice_help(Config->s_OperServ, u, OPER_HELP_SET_READONLY);
|
||||
else if (subcommand.equals_ci("LOGCHAN"))
|
||||
notice_help(Config->s_OperServ, u, OPER_HELP_SET_LOGCHAN);
|
||||
else if (subcommand.equals_ci("DEBUG"))
|
||||
notice_help(Config->s_OperServ, u, OPER_HELP_SET_DEBUG);
|
||||
else if (subcommand.equals_ci("NOEXPIRE"))
|
||||
|
||||
Reference in New Issue
Block a user