diff options
author | Adam <Adam@anope.org> | 2011-06-20 23:25:46 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-06-20 23:25:46 -0400 |
commit | 2667f9046ecd656f805d85397c27b8f19c864112 (patch) | |
tree | d2b62efaa017376d680c31a78894524a00c7b2e7 /src/logger.cpp | |
parent | a3d0ab3d09cbb636b680ab5015646ccb3200a70c (diff) |
Cleaned up some of the logger code which fixes not logging debug logs to files etc when debug is enabled, and some other small things
Diffstat (limited to 'src/logger.cpp')
-rw-r--r-- | src/logger.cpp | 82 |
1 files changed, 29 insertions, 53 deletions
diff --git a/src/logger.cpp b/src/logger.cpp index 4ccfa813f..d4d09565c 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -205,74 +205,53 @@ void LogInfo::AddType(std::list<Anope::string> &list, const Anope::string &type) list.push_back(type); } -bool LogInfo::HasType(std::list<Anope::string> &list, const Anope::string &type) const +bool LogInfo::HasType(LogType ltype, const Anope::string &type) const { - for (std::list<Anope::string>::iterator it = list.begin(), it_end = list.end(); it != it_end; ++it) - { - Anope::string cat = *it; - bool inverse = false; - if (cat[0] == '~') - { - cat.erase(cat.begin()); - inverse = true; - } - if (Anope::Match(type, cat)) - { - return !inverse; - } - } - - return false; -} - -std::list<Anope::string> &LogInfo::GetList(LogType type) -{ - static std::list<Anope::string> empty; - - switch (type) - { - case LOG_ADMIN: - return this->Admin; - case LOG_OVERRIDE: - return this->Override; - case LOG_COMMAND: - return this->Commands; - case LOG_SERVER: - return this->Servers; - case LOG_CHANNEL: - return this->Channels; - case LOG_USER: - return this->Users; - case LOG_NORMAL: - return this->Normal; - default: - return empty; - } -} - -bool LogInfo::HasType(LogType type) -{ - switch (type) + const std::list<Anope::string> *list = NULL; + switch (ltype) { case LOG_ADMIN: + list = &this->Admin; case LOG_OVERRIDE: + list = &this->Override; case LOG_COMMAND: + list = &this->Commands; case LOG_SERVER: + list = &this->Servers; case LOG_CHANNEL: + list = &this->Channels; case LOG_USER: + list = &this->Users; case LOG_NORMAL: - return !this->GetList(type).empty(); + list = &this->Normal; case LOG_TERMINAL: return true; case LOG_RAWIO: return debug ? true : this->RawIO; case LOG_DEBUG: return debug ? true : this->Debug; - // LOG_DEBUG_[234] default: break; } + if (list == NULL) + return false; + + for (std::list<Anope::string>::const_iterator it = list->begin(), it_end = list->end(); it != it_end; ++it) + { + Anope::string cat = *it; + bool inverse = false; + if (cat[0] == '~') + { + cat.erase(cat.begin()); + inverse = true; + } + if (Anope::Match(type, cat)) + { + return !inverse; + } + } + return false; } @@ -282,10 +261,7 @@ void LogInfo::ProcessMessage(const Log *l) if (!l) throw CoreException("Bad values passed to LogInfo::ProcessMessages"); - - if (!this->HasType(l->Type)) - return; - else if (!this->HasType(this->GetList(l->Type), l->Category)) + else if (!this->HasType(l->Type, l->Category)) return; if (!this->Sources.empty()) |