Module: check_mk
Branch: master
Commit: 7e796373ae0256557f3891fa4f335ebefe4cdc67
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7e796373ae0256…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Aug 30 16:55:32 2018 +0200
Improved naming and signature of a helper function.
Change-Id: If87df6da79e5da3420640a086b0ba40df0439f34
---
livestatus/src/LogCache.cc | 10 +++++-----
livestatus/src/LogCache.h | 3 +--
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/livestatus/src/LogCache.cc b/livestatus/src/LogCache.cc
index ec0358a..2506863 100644
--- a/livestatus/src/LogCache.cc
+++ b/livestatus/src/LogCache.cc
@@ -26,6 +26,7 @@
#include <sstream>
#include <string>
#include <utility>
+#include "FileSystem.h"
#include "LogEntry.h" // IWYU pragma: keep
#include "Logfile.h"
#include "Logger.h"
@@ -80,20 +81,19 @@ void LogCache::updateLogfileIndex() {
_last_index_update = std::chrono::system_clock::now();
// We need to find all relevant logfiles. This includes directory, the
// current nagios.log and all files in the archive.
- scanLogfile(_mc->historyFilePath(), true);
+ addToIndex(std::make_unique<Logfile>(_mc, _mc->historyFilePath(), true));
fs::path dirpath = _mc->logArchivePath();
try {
for (const auto &entry : fs::directory_iterator(dirpath)) {
- scanLogfile(entry.path(), false);
+ addToIndex(std::make_unique<Logfile>(_mc, entry.path(), false));
}
} catch (const fs::filesystem_error &e) {
Warning(logger()) << "updating log file index: " <<
e.what();
}
}
-void LogCache::scanLogfile(const fs::path &path, bool watch) {
- auto logfile = std::make_unique<Logfile>(_mc, path, watch);
+void LogCache::addToIndex(std::unique_ptr<Logfile> logfile) {
time_t since = logfile->since();
if (since == 0) {
return;
@@ -102,7 +102,7 @@ void LogCache::scanLogfile(const fs::path &path, bool watch) {
// circumstances this never happens, but the user might have copied files
// around.
if (_logfiles.find(since) != _logfiles.end()) {
- Warning(logger()) << "ignoring duplicate log file " <<
path;
+ Warning(logger()) << "ignoring duplicate log file " <<
logfile->path();
return;
}
diff --git a/livestatus/src/LogCache.h b/livestatus/src/LogCache.h
index 2031b63..84e9ceb 100644
--- a/livestatus/src/LogCache.h
+++ b/livestatus/src/LogCache.h
@@ -31,7 +31,6 @@
#include <map>
#include <memory>
#include <mutex>
-#include "FileSystem.h"
class Logfile;
class Logger;
class MonitoringCore;
@@ -59,7 +58,7 @@ private:
logfiles_t _logfiles;
std::chrono::system_clock::time_point _last_index_update;
- void scanLogfile(const fs::path &path, bool watch);
+ void addToIndex(std::unique_ptr<Logfile> logfile);
Logger *logger() const;
};