diff options
-rw-r--r-- | data/example.conf | 6 | ||||
-rw-r--r-- | include/logger.h | 1 | ||||
-rw-r--r-- | src/config.cpp | 1 | ||||
-rw-r--r-- | src/logger.cpp | 26 |
4 files changed, 19 insertions, 15 deletions
diff --git a/data/example.conf b/data/example.conf index aea4c07f3..1c0737cbd 100644 --- a/data/example.conf +++ b/data/example.conf @@ -678,6 +678,12 @@ log #source = "" /* + * The bot used to log generic messages which have no predefined sender if there + * is a channel in the target directive. + */ + bot = "Global" + + /* * The number of days to keep logfiles, only useful if you are logging to a file. * Set to 0 to never delete old logfiles. * diff --git a/include/logger.h b/include/logger.h index afa874ca3..b97839732 100644 --- a/include/logger.h +++ b/include/logger.h @@ -109,6 +109,7 @@ class CoreExport Log class CoreExport LogInfo { public: + BotInfo *bot; std::vector<Anope::string> targets; std::vector<LogFile *> logfiles; int last_day; diff --git a/src/config.cpp b/src/config.cpp index 07b51f99e..1adcd624a 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -387,6 +387,7 @@ Conf::Conf() : Block("") LogInfo l(logage, rawio, debug); + l.bot = BotInfo::Find(log->Get<const Anope::string>("bot", "Global")); spacesepstream(log->Get<const Anope::string>("target")).GetTokens(l.targets); spacesepstream(log->Get<const Anope::string>("source")).GetTokens(l.sources); spacesepstream(log->Get<const Anope::string>("admin")).GetTokens(l.admin); diff --git a/src/logger.cpp b/src/logger.cpp index d071b7cc3..380e94b14 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -77,8 +77,6 @@ const Anope::string &LogFile::GetName() const Log::Log(LogType t, const Anope::string &cat, const BotInfo *b) : bi(b), u(NULL), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), type(t), category(cat) { - if (!bi && Config) - bi = Global; } Log::Log(LogType t, CommandSource &source, Command *_c, const ChannelInfo *_ci) : nick(source.GetNick()), u(source.GetUser()), nc(source.nc), c(_c), chan(NULL), ci(_ci), s(NULL), m(NULL), type(t) @@ -93,8 +91,6 @@ Log::Log(LogType t, CommandSource &source, Command *_c, const ChannelInfo *_ci) this->bi = NULL; if (sl != Anope::string::npos) this->bi = BotInfo::Find(c->name.substr(0, sl)); - if (this->bi == NULL && Config) - this->bi = Global; this->category = c->name; } @@ -111,9 +107,6 @@ Log::Log(const User *_u, const Anope::string &cat, const BotInfo *_bi) : bi(_bi) { if (!u) throw CoreException("Invalid pointers passed to Log::Log"); - - if (!this->bi && Config) - this->bi = Global; } Log::Log(Server *serv, const Anope::string &cat, const BotInfo *_bi) : bi(_bi), u(NULL), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(serv), m(NULL), type(LOG_SERVER), category(cat) @@ -121,16 +114,12 @@ Log::Log(Server *serv, const Anope::string &cat, const BotInfo *_bi) : bi(_bi), if (!s) throw CoreException("Invalid pointer passed to Log::Log"); - if (!this->bi && Config) + if (!this->bi) this->bi = OperServ; - if (!this->bi && Config) - this->bi = Global; } Log::Log(const BotInfo *b, const Anope::string &cat) : bi(b), u(NULL), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), m(NULL), type(LOG_NORMAL), category(cat) { - if (!this->bi && Config) - this->bi = Global; } Log::Log(Module *mod, const Anope::string &cat) : bi(NULL), u(NULL), nc(NULL), c(NULL), chan(NULL), ci(NULL), s(NULL), m(mod), type(LOG_MODULE), category(cat) @@ -243,7 +232,7 @@ Anope::string Log::BuildPrefix() const return buffer; } -LogInfo::LogInfo(int la, bool rio, bool ldebug) : last_day(0), log_age(la), raw_io(rio), debug(ldebug) +LogInfo::LogInfo(int la, bool rio, bool ldebug) : bot(NULL), last_day(0), log_age(la), raw_io(rio), debug(ldebug) { } @@ -376,9 +365,16 @@ void LogInfo::ProcessMessage(const Log *l) if (UplinkSock && l->type <= LOG_NORMAL && Me && Me->IsSynced()) { Channel *c = Channel::Find(target); - if (!c || !l->bi) + if (!c) continue; - IRCD->SendPrivmsg(l->bi, c->name, "%s", buffer.c_str()); + + const BotInfo *bi = l->bi; + if (!bi) + bi = this->bot; + if (!bi) + bi = c->ci->WhoSends(); + if (bi) + IRCD->SendPrivmsg(bi, c->name, "%s", buffer.c_str()); } } else if (target == "globops") |