diff options
author | Adam <Adam@anope.org> | 2016-07-28 21:29:35 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2016-07-28 21:29:35 -0400 |
commit | 0e758a2ac23dc4a001e8e126cec14588da9a9769 (patch) | |
tree | 45df813323e023c5c89db7279426c4ad0943b4a9 /src/logger.cpp | |
parent | a3c8afae00c54d5b95c620248b51f90679d7d53f (diff) |
Allow serializable fields to use storage in the respective objects.
Split service management code nito a proper servicemanager. Make service
references managed instead of lazy lookup. Also made events and
serializable use service manager instead of their respective systems for
management
Diffstat (limited to 'src/logger.cpp')
-rw-r--r-- | src/logger.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/logger.cpp b/src/logger.cpp index 3a735d48d..7be130d0b 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -90,11 +90,11 @@ Log::Log(LogType t, CommandSource &src, Command *_c, ChanServ::Channel *_ci) : u if (type != LOG_COMMAND && type != LOG_OVERRIDE && type != LOG_ADMIN) throw CoreException("This constructor does not support this log type"); - size_t sl = c->name.find('/'); + size_t sl = c->GetName().find('/'); this->bi = NULL; if (sl != Anope::string::npos) - this->bi = ServiceBot::Find(c->name.substr(0, sl), true); - this->category = c->name; + this->bi = ServiceBot::Find(c->GetName().substr(0, sl), true); + this->category = c->GetName(); } Log::Log(User *_u, Channel *ch, const Anope::string &cat) : bi(NULL), u(_u), nc(NULL), c(NULL), source(NULL), chan(ch), ci(chan ? *chan->ci : NULL), s(NULL), m(NULL), type(LOG_CHANNEL), category(cat) @@ -132,7 +132,15 @@ Log::~Log() else if (this->type == LOG_TERMINAL) std::cout << this->BuildPrefix() << this->buf.str() << std::endl; - Event::OnLog(&Event::Log::OnLog, this); + /* Some of the higher debug messages are in the event/service system which manages event dispatch, + * so firing off the log event here can cause them to be in weird states + */ + if (this->type <= LOG_NORMAL) + { + EventManager *em = EventManager::Get(); + if (em != nullptr) + em->Dispatch(&Event::Log::OnLog, this); + } if (Config) for (unsigned i = 0; i < Config->LogInfos.size(); ++i) @@ -154,7 +162,7 @@ Anope::string Log::FormatSource() const Anope::string Log::FormatCommand() const { - Anope::string buffer = FormatSource() + " used " + (source != NULL && !source->command.empty() ? source->command : this->c->name) + " "; + Anope::string buffer = FormatSource() + " used " + (source != NULL && !source->command.empty() ? source->command : this->c->GetName()) + " "; if (this->ci) buffer += "on " + this->ci->GetName() + " "; @@ -348,7 +356,7 @@ void LogInfo::ProcessMessage(const Log *l) const Anope::string &buffer = l->BuildPrefix() + l->buf.str(); - Event::OnLogMessage(&Event::LogMessage::OnLogMessage, this, l, buffer); + EventManager::Get()->Dispatch(&Event::LogMessage::OnLogMessage, this, l, buffer); for (unsigned i = 0; i < this->targets.size(); ++i) { |