diff options
Diffstat (limited to 'src/logger.cpp')
-rw-r--r-- | src/logger.cpp | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/src/logger.cpp b/src/logger.cpp index 532369c3b..fb4b4bea8 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -130,9 +130,13 @@ Log::~Log() FOREACH_MOD(OnLog, (this)); if (Config) - for (unsigned i = 0; i < Config->LogInfos.size(); ++i) - if (Config->LogInfos[i].HasType(this->type, this->category)) - Config->LogInfos[i].ProcessMessage(this); + { + for (auto &li : Config->LogInfos) + { + if (li.HasType(this->type, this->category)) + li.ProcessMessage(this); + } + } } Anope::string Log::FormatSource() const @@ -232,8 +236,8 @@ LogInfo::LogInfo(int la, bool rio, bool ldebug) : log_age(la), raw_io(rio), debu LogInfo::~LogInfo() { - for (unsigned i = 0; i < this->logfiles.size(); ++i) - delete this->logfiles[i]; + for (const auto *logfile : this->logfiles) + delete logfile; this->logfiles.clear(); } @@ -280,16 +284,15 @@ bool LogInfo::HasType(LogType ltype, const Anope::string &type) const if (list == NULL) return false; - for (unsigned i = 0; i < list->size(); ++i) + for (auto value : *list) { - Anope::string cat = list->at(i); bool inverse = false; - if (cat[0] == '~') + if (value[0] == '~') { - cat.erase(cat.begin()); + value.erase(value.begin()); inverse = true; } - if (Anope::Match(type, cat)) + if (Anope::Match(type, value)) { return !inverse; } @@ -300,14 +303,12 @@ bool LogInfo::HasType(LogType ltype, const Anope::string &type) const void LogInfo::OpenLogFiles() { - for (unsigned i = 0; i < this->logfiles.size(); ++i) - delete this->logfiles[i]; + for (const auto *logfile : this->logfiles) + delete logfile; this->logfiles.clear(); - for (unsigned i = 0; i < this->targets.size(); ++i) + for (const auto &target : this->targets) { - const Anope::string &target = this->targets[i]; - if (target.empty() || target[0] == '#' || target == "globops" || target.find(":") != Anope::string::npos) continue; @@ -352,10 +353,8 @@ void LogInfo::ProcessMessage(const Log *l) FOREACH_MOD(OnLogMessage, (this, l, buffer)); - for (unsigned i = 0; i < this->targets.size(); ++i) + for (const auto &target : this->targets) { - const Anope::string &target = this->targets[i]; - if (!target.empty() && target[0] == '#') { if (UplinkSock && l->type <= LOG_NORMAL && Me && Me->IsSynced()) @@ -393,11 +392,10 @@ void LogInfo::ProcessMessage(const Log *l) this->OpenLogFiles(); if (this->log_age) - for (unsigned i = 0; i < this->targets.size(); ++i) + { + for (const auto &target : this->targets) { - const Anope::string &target = this->targets[i]; - - if (target.empty() || target[0] == '#' || target == "globops" || target.find(":") != Anope::string::npos) + if (target.empty() || target[0] == '#' || target == "globops" || target.find(":") != Anope::string::npos) continue; Anope::string oldlog = CreateLogName(target, Anope::CurTime - 86400 * this->log_age); @@ -407,11 +405,11 @@ void LogInfo::ProcessMessage(const Log *l) Log(LOG_DEBUG) << "Deleted old logfile " << oldlog; } } + } } - for (unsigned i = 0; i < this->logfiles.size(); ++i) + for (auto *lf : this->logfiles) { - LogFile *lf = this->logfiles[i]; lf->stream << GetTimeStamp() << " " << buffer << std::endl; } } |