summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Matyushin <[email protected]>2015-08-09 20:03:29 +0300
committerVyacheslav Matyushin <[email protected]>2015-08-09 20:03:29 +0300
commit1f266245e530b0a890db93144e47475ac1bed74f (patch)
tree48efc48d1de6a184d5692b5ca5e84f2acbc71c15
parentad6463b6d59b7876afe4ef7fe6050b4f39a0011c (diff)
Initial filtering support.
-rw-r--r--src/modes/journald/journaldLocalAnalyzer.cpp17
-rw-r--r--src/modes/journald/journaldLocalAnalyzer.h3
-rw-r--r--src/modes/journald/journaldLogMode.cpp1
3 files changed, 16 insertions, 5 deletions
diff --git a/src/modes/journald/journaldLocalAnalyzer.cpp b/src/modes/journald/journaldLocalAnalyzer.cpp
index b786ea1..e63aa6e 100644
--- a/src/modes/journald/journaldLocalAnalyzer.cpp
+++ b/src/modes/journald/journaldLocalAnalyzer.cpp
@@ -31,7 +31,7 @@
#include <QtConcurrent/QtConcurrent>
-JournaldLocalAnalyzer::JournaldLocalAnalyzer(LogMode *logMode)
+JournaldLocalAnalyzer::JournaldLocalAnalyzer(LogMode *logMode, QString filter)
: Analyzer(logMode)
{
m_cursor = nullptr;
@@ -51,7 +51,13 @@ JournaldLocalAnalyzer::JournaldLocalAnalyzer(LogMode *logMode)
m_journalNotifier->setEnabled(false);
connect(m_journalNotifier, SIGNAL(activated(int)), this, SLOT(journalDescriptorUpdated(int)));
- fillCurrentBootID();
+ if (configuration->displayCurrentBootOnly()) {
+ fillCurrentBootID();
+ m_filters << QString("_BOOT_ID=%1").arg(m_currentBootID);
+ }
+
+ if (!filter.isEmpty())
+ m_filters << filter;
}
JournaldLocalAnalyzer::~JournaldLocalAnalyzer()
@@ -91,7 +97,7 @@ void JournaldLocalAnalyzer::watchLogFiles(bool enabled)
m_journalWatchers.append(watcher);
m_workerMutex.unlock();
connect(watcher, SIGNAL(finished()), this, SLOT(readJournalInitialFinished()));
- watcher->setFuture(QtConcurrent::run(this, &JournaldLocalAnalyzer::readJournal, QStringList()));
+ watcher->setFuture(QtConcurrent::run(this, &JournaldLocalAnalyzer::readJournal, m_filters));
} else {
for (JournalWatcher *watcher : m_journalWatchers) {
watcher->waitForFinished();
@@ -192,7 +198,7 @@ void JournaldLocalAnalyzer::journalDescriptorUpdated(int fd)
m_journalWatchers.append(watcher);
m_workerMutex.unlock();
connect(watcher, SIGNAL(finished()), this, SLOT(readJournalUpdateFinished()));
- watcher->setFuture(QtConcurrent::run(this, &JournaldLocalAnalyzer::readJournal, QStringList()));
+ watcher->setFuture(QtConcurrent::run(this, &JournaldLocalAnalyzer::readJournal, m_filters));
}
QList<JournaldLocalAnalyzer::JournalEntry> JournaldLocalAnalyzer::readJournal(const QStringList &filters)
@@ -285,6 +291,9 @@ QList<JournaldLocalAnalyzer::JournalEntry> JournaldLocalAnalyzer::readJournal(co
// Return to the first new entry.
sd_journal_seek_cursor(journal, m_cursor);
sd_journal_next(journal);
+ } else {
+ // Return to the beginning of the journal.
+ sd_journal_seek_head(journal);
}
}
diff --git a/src/modes/journald/journaldLocalAnalyzer.h b/src/modes/journald/journaldLocalAnalyzer.h
index c2a7ce4..ee24395 100644
--- a/src/modes/journald/journaldLocalAnalyzer.h
+++ b/src/modes/journald/journaldLocalAnalyzer.h
@@ -36,7 +36,7 @@ class JournaldLocalAnalyzer : public Analyzer
Q_OBJECT
public:
- explicit JournaldLocalAnalyzer(LogMode *logMode);
+ explicit JournaldLocalAnalyzer(LogMode *logMode, QString filter = QString());
virtual ~JournaldLocalAnalyzer();
@@ -76,6 +76,7 @@ private:
sd_journal *m_journal;
int m_journalFlags;
QString m_currentBootID;
+ QStringList m_filters;
char *m_cursor;
QMutex m_workerMutex;
diff --git a/src/modes/journald/journaldLogMode.cpp b/src/modes/journald/journaldLogMode.cpp
index c004c3a..72ffa03 100644
--- a/src/modes/journald/journaldLogMode.cpp
+++ b/src/modes/journald/journaldLogMode.cpp
@@ -54,6 +54,7 @@ Analyzer *JournaldLogMode::createAnalyzer(const QVariant &options)
JournaldAnalyzerOptions analyzerOptions = options.value<JournaldAnalyzerOptions>();
switch (analyzerOptions.analyzerType) {
case JournaldAnalyzerType::Local:
+ return new JournaldLocalAnalyzer(this, analyzerOptions.filter);
break;
case JournaldAnalyzerType::Network:
break;