summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Matyushin <[email protected]>2015-06-15 12:20:42 +0300
committerVyacheslav Matyushin <[email protected]>2015-06-15 12:20:42 +0300
commit1769a5ee03d4a93fb1b7d25740f90a07ca8903ec (patch)
tree8d5501059b4ede39a3e5aa6defb56fa2ae01a630
parent305d07c8040775f71b3efaac72511b224c1ccc5b (diff)
Added dummy journald mode.
The mode does nothing yet. Analyzer class is split into Analyzer and FileAnalyzer. JournaldAnalyzer is based on Analyzer. All other mode analyzers are using FileAnalyzer.
-rw-r--r--CMakeLists.txt21
-rw-r--r--src/CMakeLists.txt105
-rw-r--r--src/lib/CMakeLists.txt91
-rw-r--r--src/lib/analyzer.cpp187
-rw-r--r--src/lib/analyzer.h40
-rw-r--r--src/lib/fileAnalyzer.cpp235
-rw-r--r--src/lib/fileAnalyzer.h88
-rw-r--r--src/logModePluginsLoader.cpp4
-rw-r--r--src/modes/acpid/acpidAnalyzer.h6
-rw-r--r--src/modes/apache/apacheAccessAnalyzer.h6
-rw-r--r--src/modes/apache/apacheAnalyzer.h6
-rw-r--r--src/modes/base/syslogAnalyzer.cpp2
-rw-r--r--src/modes/base/syslogAnalyzer.h4
-rw-r--r--src/modes/cups/cupsAccessAnalyzer.h6
-rw-r--r--src/modes/cups/cupsAnalyzer.h6
-rw-r--r--src/modes/cups/cupsPageAnalyzer.h6
-rw-r--r--src/modes/cups/cupsPdfAnalyzer.h6
-rw-r--r--src/modes/journald/CMakeLists.txt35
-rw-r--r--src/modes/journald/journaldAnalyzer.cpp67
-rw-r--r--src/modes/journald/journaldAnalyzer.h52
-rw-r--r--src/modes/journald/journaldConfiguration.cpp22
-rw-r--r--src/modes/journald/journaldConfiguration.h52
-rw-r--r--src/modes/journald/journaldConfigurationWidget.cpp22
-rw-r--r--src/modes/journald/journaldConfigurationWidget.h92
-rw-r--r--src/modes/journald/journaldConfigurationWidget.ui39
-rw-r--r--src/modes/journald/journaldFactory.cpp47
-rw-r--r--src/modes/journald/journaldFactory.h42
-rw-r--r--src/modes/journald/journaldLogMode.cpp66
-rw-r--r--src/modes/journald/journaldLogMode.h54
-rw-r--r--src/modes/kernel/kernelAnalyzer.h6
-rw-r--r--src/modes/samba/sambaAnalyzer.h6
-rw-r--r--src/modes/xorg/xorgAnalyzer.h6
-rw-r--r--src/modes/xsession/xsessionAnalyzer.h6
33 files changed, 1068 insertions, 365 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index faa942a..7c3425b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,14 +52,14 @@ include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
# Help Eclipse to parse errors more efficiently
if(CMAKE_COMPILER_IS_GNUCC)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
endif(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0")
endif(CMAKE_COMPILER_IS_GNUCXX)
-add_custom_target(
+add_custom_target(
pkg
COMMAND ./build-package.sh
)
@@ -74,10 +74,10 @@ add_custom_target(
########### Subfolders ##########
-add_subdirectory(src)
+add_subdirectory(src)
add_subdirectory(src/lib)
add_subdirectory(src/config)
-
+
add_subdirectory(src/modes/base)
add_subdirectory(src/modes/open)
@@ -85,16 +85,17 @@ add_subdirectory(src/modes/system)
add_subdirectory(src/modes/kernel)
add_subdirectory(src/modes/xorg)
add_subdirectory(src/modes/cron)
-add_subdirectory(src/modes/authentication)
-add_subdirectory(src/modes/daemon)
+add_subdirectory(src/modes/authentication)
+add_subdirectory(src/modes/daemon)
add_subdirectory(src/modes/acpid)
add_subdirectory(src/modes/xsession)
-add_subdirectory(src/modes/apache)
-add_subdirectory(src/modes/postfix)
+add_subdirectory(src/modes/apache)
+add_subdirectory(src/modes/postfix)
add_subdirectory(src/modes/samba)
add_subdirectory(src/modes/cups)
+add_subdirectory(src/modes/journald)
-add_subdirectory(tests)
+add_subdirectory(tests)
add_subdirectory(doc)
find_package(KF5I18n CONFIG REQUIRED)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a125ffa..405f170 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,70 +1,71 @@
########### Build ###############
-include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}/config
- ${CMAKE_CURRENT_SOURCE_DIR}/lib
- ${CMAKE_CURRENT_BINARY_DIR}/config
- ${CMAKE_CURRENT_BINARY_DIR}/lib
- ${CMAKE_CURRENT_SOURCE_DIR}
-
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/open
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}/config
+ ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ ${CMAKE_CURRENT_BINARY_DIR}/config
+ ${CMAKE_CURRENT_BINARY_DIR}/lib
+ ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/system
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/kernel
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/daemon
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/xorg
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/cron
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/acpid
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/xsession
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/apache
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/cups
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/samba
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/authentication
- ${CMAKE_CURRENT_SOURCE_DIR}/modes/postfix
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/open
+
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/system
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/kernel
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/daemon
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/xorg
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/cron
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/acpid
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/xsession
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/apache
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/cups
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/samba
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/authentication
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/postfix
+ ${CMAKE_CURRENT_SOURCE_DIR}/modes/journald
)
set(ksystemlog_sources
- main.cpp
- mainWindow.cpp
- logModePluginsLoader.cpp
- loggerDialog.cpp
- detailDialog.cpp
- generalConfigurationWidget.cpp
- configurationDialog.cpp
- tabLogViewsWidget.cpp
- tabLogManager.cpp
- statusBar.cpp
-
+ main.cpp
+ mainWindow.cpp
+ logModePluginsLoader.cpp
+ loggerDialog.cpp
+ detailDialog.cpp
+ generalConfigurationWidget.cpp
+ configurationDialog.cpp
+ tabLogViewsWidget.cpp
+ tabLogManager.cpp
+ statusBar.cpp
)
ki18n_wrap_ui(ksystemlog_sources
- detailDialogBase.ui
- loggerDialogBase.ui
- generalConfigurationWidgetBase.ui
+ detailDialogBase.ui
+ loggerDialogBase.ui
+ generalConfigurationWidgetBase.ui
)
add_executable(ksystemlog ${ksystemlog_sources})
-target_link_libraries(ksystemlog
- ksystemlog_lib
- ksystemlog_config
- ksystemlog_open
- ksystemlog_system
- ksystemlog_kernel
- ksystemlog_xorg
- ksystemlog_cron
- ksystemlog_apache
- ksystemlog_authentication
- ksystemlog_daemon
- ksystemlog_acpid
- ksystemlog_xsession
- ksystemlog_postfix
- ksystemlog_cups
- ksystemlog_samba
+target_link_libraries(ksystemlog
+ ksystemlog_lib
+ ksystemlog_config
+ ksystemlog_open
+ ksystemlog_system
+ ksystemlog_kernel
+ ksystemlog_xorg
+ ksystemlog_cron
+ ksystemlog_apache
+ ksystemlog_authentication
+ ksystemlog_daemon
+ ksystemlog_acpid
+ ksystemlog_xsession
+ ksystemlog_postfix
+ ksystemlog_cups
+ ksystemlog_journald
+ ksystemlog_samba
- KF5::Archive
- KF5::TextWidgets
+ KF5::Archive
+ KF5::TextWidgets
)
########### Installation ###############
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index c1e02fe..5cabcba 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -1,42 +1,41 @@
-include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/..
- ${CMAKE_CURRENT_BINARY_DIR}/../config
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/..
+ ${CMAKE_CURRENT_BINARY_DIR}/../config
)
set(ksystemlog_lib_sources
- analyzer.cpp
- logModeFactory.cpp
- logModeConfiguration.cpp
- logModeConfigurationWidget.cpp
- logModeItemBuilder.cpp
- logManager.cpp
- view.cpp
- globals.cpp
- logMode.cpp
- logLevel.cpp
- logFile.cpp
- logFileReader.cpp
- localLogFileReader.cpp
- processOutputLogFileReader.cpp
- kioLogFileReader.cpp
- logLine.cpp
- logViewModel.cpp
- logViewColumn.cpp
- logViewColumns.cpp
- logViewWidgetItem.cpp
- logViewWidget.cpp
- logViewExport.cpp
- logViewFilterWidget.cpp
- logViewSearchWidget.cpp
- loadingBar.cpp
- logModeAction.cpp
- simpleAction.cpp
- multipleActions.cpp
-
- levelPrintPage.cpp
-
+ analyzer.cpp
+ fileAnalyzer.cpp
+ logModeFactory.cpp
+ logModeConfiguration.cpp
+ logModeConfigurationWidget.cpp
+ logModeItemBuilder.cpp
+ logManager.cpp
+ view.cpp
+ globals.cpp
+ logMode.cpp
+ logLevel.cpp
+ logFile.cpp
+ logFileReader.cpp
+ localLogFileReader.cpp
+ processOutputLogFileReader.cpp
+ kioLogFileReader.cpp
+ logLine.cpp
+ logViewModel.cpp
+ logViewColumn.cpp
+ logViewColumns.cpp
+ logViewWidgetItem.cpp
+ logViewWidget.cpp
+ logViewExport.cpp
+ logViewFilterWidget.cpp
+ logViewSearchWidget.cpp
+ loadingBar.cpp
+ logModeAction.cpp
+ simpleAction.cpp
+ multipleActions.cpp
+ levelPrintPage.cpp
)
ki18n_wrap_ui(ksystemlog_lib_sources logViewSearchWidgetBase.ui)
@@ -44,20 +43,20 @@ ki18n_wrap_ui(ksystemlog_lib_sources logViewSearchWidgetBase.ui)
add_library(ksystemlog_lib STATIC ${ksystemlog_lib_sources})
add_dependencies(
- ksystemlog_lib
- ksystemlog_config
+ ksystemlog_lib
+ ksystemlog_config
)
target_link_libraries(ksystemlog_lib
- ksystemlog_config
-
- KF5::I18n
- KF5::Archive
- KF5::ConfigWidgets
- KF5::ItemViews
- KF5::IconThemes
- KF5::KIOCore
- KF5::Completion
+ ksystemlog_config
+
+ KF5::I18n
+ KF5::Archive
+ KF5::ConfigWidgets
+ KF5::ItemViews
+ KF5::IconThemes
+ KF5::KIOCore
+ KF5::Completion
)
qt5_use_modules(ksystemlog_lib Widgets PrintSupport)
diff --git a/src/lib/analyzer.cpp b/src/lib/analyzer.cpp
index f75590f..07983ad 100644
--- a/src/lib/analyzer.cpp
+++ b/src/lib/analyzer.cpp
@@ -46,38 +46,10 @@ Analyzer::Analyzer(LogMode *logMode)
Analyzer::~Analyzer()
{
- deleteLogFiles();
-
// logMode is managed by Globals
// logViewModel is managed by LogViewWidget
}
-void Analyzer::watchLogFiles(bool enabled)
-{
- // Enable the log file watching, by revert order to read the most top file at last, and be sure its line
- // will be kept
-
- QListIterator<LogFileReader *> it(logFileReaders);
- it.toBack();
- while (it.hasPrevious()) {
- LogFileReader *logFileReader = it.previous();
- logFileReader->watchFile(enabled);
- }
-}
-
-void Analyzer::deleteLogFiles()
-{
- watchLogFiles(false);
-
- // Remove the watching on the monitored files
- foreach (LogFileReader *logFileReader, logFileReaders) {
- logDebug() << "Remove file : " << logFileReader->logFile().url().path();
- delete logFileReader;
- }
-
- logFileReaders.clear();
-}
-
bool Analyzer::isParsingPaused() const
{
return parsingPaused;
@@ -104,162 +76,3 @@ void Analyzer::setLogViewModel(LogViewModel *logViewModel)
{
this->logViewModel = logViewModel;
}
-
-void Analyzer::setLogFiles(const QList<LogFile> &logFiles)
-{
- // Remove previous files
- deleteLogFiles();
-
- foreach (const LogFile &logFile, logFiles) {
- LogFileReader *logFileReader = createLogFileReader(logFile);
- logFileReaders.append(logFileReader);
-
- connect(logFileReader, SIGNAL(contentChanged(LogFileReader *, Analyzer::ReadingMode, QStringList)),
- this, SLOT(logFileChanged(LogFileReader *, Analyzer::ReadingMode, QStringList)));
- connect(logFileReader, SIGNAL(statusBarChanged(QString)), this, SIGNAL(statusBarChanged(QString)));
- connect(logFileReader, SIGNAL(errorOccured(QString, QString)), this,
- SIGNAL(errorOccured(QString, QString)));
- }
-}
-
-void Analyzer::logFileChanged(LogFileReader *logFileReader, ReadingMode readingMode,
- const QStringList &content)
-{
- if (readingMode == Analyzer::FullRead)
- logDebug() << "File " << logFileReader->logFile().url().path() << " has been modified on full read.";
- else
- logDebug() << "File " << logFileReader->logFile().url().path()
- << " has been modified on partial read";
-
- if (parsingPaused == true) {
- logDebug() << "Pause enabled. Nothing read.";
- return;
- }
-
- logDebug() << "Locking file modifications of " << logFileReader->logFile().url().path();
- insertionLocking->lock();
- logDebug() << "Unlocking file modifications of " << logFileReader->logFile().url().path();
-
- QTime benchmark;
- benchmark.start();
-
- int insertedLogLineCount;
-
- logViewModel->startingMultipleInsertions(readingMode);
-
- if (readingMode == Analyzer::UpdatingRead) {
- insertedLogLineCount = insertLines(content, logFileReader->logFile(), Analyzer::UpdatingRead);
- } else {
- logDebug() << "Reading file " << logFileReader->logFile().url().path();
-
- emit statusBarChanged(i18n("Opening '%1'...", logFileReader->logFile().url().path()));
-
- // Inform that we are now reading the "index" file
- emit readFileStarted(*logMode, logFileReader->logFile(),
- logFileReaders.count() - logFileReaders.indexOf(logFileReader),
- logFileReaders.count());
-
- insertedLogLineCount = insertLines(content, logFileReader->logFile(), Analyzer::FullRead);
-
- emit statusBarChanged(
- i18n("Log file '%1' loaded successfully.", logFileReader->logFile().url().path()));
- }
-
- logViewModel->endingMultipleInsertions(readingMode, insertedLogLineCount);
-
- // Inform connected LoadingBar that the reading is now finished
- emit readEnded();
-
- // Inform LogManager that new lines have been added
- emit logUpdated(insertedLogLineCount);
-
- // Inform MainWindow status bar
- emit statusBarChanged(i18n("Log file '%1' has changed.", logFileReader->logFile().url().path()));
-
- logDebug() << "Updating log files in " << benchmark.elapsed() << " ms";
-
- insertionLocking->unlock();
-}
-
-int Analyzer::insertLines(const QStringList &bufferedLines, const LogFile &logFile, ReadingMode readingMode)
-{
- logDebug() << "Inserting lines...";
-
- // If there is no line
- if (bufferedLines.size() == 0) {
- logWarning() << "File is empty : " << logFile.url().path();
- }
-
- int stop = 0;
- int currentPosition = 0;
-
- QListIterator<QString> it(bufferedLines);
- /**
- * If the log file is sorted, then we can ignore the first lines
- * if there are more lines in the log file than the max lines
- *
- * TODO Read revertly the file and ignore last lines if we are in Descending mode
- */
- logDebug() << "Log file Sort mode is " << logFileSortMode();
- if (logFileSortMode() == Analyzer::AscendingSortedLogFile) {
- // Calculate how many lines we will ignore
- if (bufferedLines.size() > KSystemLogConfig::maxLines()) {
- stop = bufferedLines.size() - KSystemLogConfig::maxLines();
- }
-
- // Ignore those lines
- while (currentPosition < stop) {
- it.next();
- ++currentPosition;
- }
- }
-
- int insertedLogLineCount = 0;
- while (currentPosition < bufferedLines.size()) {
- QString buffer(it.next());
-
- bool inserted = insertLine(buffer, logFile, readingMode);
- if (inserted) {
- insertedLogLineCount++;
- }
-
- if (readingMode == Analyzer::FullRead) {
- informOpeningProgress(currentPosition, (bufferedLines.size() - 1) - stop);
- }
-
- ++currentPosition;
- }
-
- logDebug() << "Total read lines :" << (bufferedLines.size() - stop) << "(" << logFile.url().path() << ")";
-
- return insertedLogLineCount;
-}
-
-bool Analyzer::insertLine(const QString &buffer, const LogFile &originalFile, ReadingMode readingMode)
-{
- LogLine *line = parseMessage(buffer, originalFile);
-
- // Invalid log line
- if (line == NULL) {
- return false;
- }
-
- // On full reading, it is not needed to display the recent status
- if (readingMode == Analyzer::FullRead) {
- line->setRecent(false);
- }
-
- return logViewModel->insertNewLogLine(line);
-}
-
-inline void Analyzer::informOpeningProgress(int currentPosition, int total)
-{
- int each = total / 100;
- if (each == 0) {
- return;
- }
-
- if (currentPosition % each == 0) {
- emit openingProgressed();
- }
-}
diff --git a/src/lib/analyzer.h b/src/lib/analyzer.h
index b84f98e..fe67dfd 100644
--- a/src/lib/analyzer.h
+++ b/src/lib/analyzer.h
@@ -52,47 +52,21 @@ public:
explicit Analyzer(LogMode *logMode);
- ~Analyzer();
+ virtual ~Analyzer();
- void watchLogFiles(bool enabled);
+ virtual void watchLogFiles(bool enabled) = 0;
+
+ virtual void setLogFiles(const QList<LogFile> &logFiles) = 0;
+
+ virtual LogViewColumns initColumns() = 0;
- void setLogFiles(const QList<LogFile> &logFiles);
void setLogViewModel(LogViewModel *logViewModel);
bool isParsingPaused() const;
- virtual LogViewColumns initColumns() = 0;
-
public slots:
void setParsingPaused(bool paused);
-protected:
- virtual LogFileReader *createLogFileReader(const LogFile &logFile) = 0;
- virtual Analyzer::LogFileSortMode logFileSortMode() = 0;
-
- virtual LogLine *parseMessage(const QString &logLine, const LogFile &originalFile) = 0;
-
-private:
- inline void informOpeningProgress(int currentPosition, int total);
-
- void deleteLogFiles();
-
- /**
- * Parse and insert the buffered lines in the model
- * Returns the count of inserted lines
- */
- int insertLines(const QStringList &bufferedLines, const LogFile &logFile, ReadingMode readingMode);
-
- /**
- * Parse and insert a line in the model
- * Returns false if it was not inserted, true if it was
- */
- bool insertLine(const QString &buffer, const LogFile &originalFile, ReadingMode readingMode);
-
-private slots:
- void logFileChanged(LogFileReader *logFileReader, Analyzer::ReadingMode readingMode,
- const QStringList &content);
-
signals:
void statusBarChanged(const QString &message);
void errorOccured(const QString &title, const QString &message);
@@ -112,8 +86,6 @@ protected:
LogMode *logMode;
- QList<LogFileReader *> logFileReaders;
-
QMutex *insertionLocking;
long logLineInternalIdGenerator;
diff --git a/src/lib/fileAnalyzer.cpp b/src/lib/fileAnalyzer.cpp
new file mode 100644
index 0000000..9e5abcd
--- /dev/null
+++ b/src/lib/fileAnalyzer.cpp
@@ -0,0 +1,235 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include "fileAnalyzer.h"
+
+#include <KLocalizedString>
+
+#include "logging.h"
+#include "ksystemlogConfig.h"
+
+#include "logViewModel.h"
+
+#include "logMode.h"
+#include "logFileReader.h"
+
+#include "logFile.h"
+
+FileAnalyzer::FileAnalyzer(LogMode *logMode)
+ : Analyzer(logMode)
+{
+ parsingPaused = false;
+
+ insertionLocking = new QMutex(QMutex::Recursive);
+}
+
+FileAnalyzer::~FileAnalyzer()
+{
+ deleteLogFiles();
+
+ // logMode is managed by Globals
+ // logViewModel is managed by LogViewWidget
+}
+
+void FileAnalyzer::watchLogFiles(bool enabled)
+{
+ // Enable the log file watching, by revert order to read the most top file at last, and be sure its line
+ // will be kept
+
+ QListIterator<LogFileReader *> it(logFileReaders);
+ it.toBack();
+ while (it.hasPrevious()) {
+ LogFileReader *logFileReader = it.previous();
+ logFileReader->watchFile(enabled);
+ }
+}
+
+void FileAnalyzer::deleteLogFiles()
+{
+ watchLogFiles(false);
+
+ // Remove the watching on the monitored files
+ foreach (LogFileReader *logFileReader, logFileReaders) {
+ logDebug() << "Remove file : " << logFileReader->logFile().url().path();
+ delete logFileReader;
+ }
+
+ logFileReaders.clear();
+}
+
+void FileAnalyzer::setLogFiles(const QList<LogFile> &logFiles)
+{
+ // Remove previous files
+ deleteLogFiles();
+
+ foreach (const LogFile &logFile, logFiles) {
+ LogFileReader *logFileReader = createLogFileReader(logFile);
+ logFileReaders.append(logFileReader);
+
+ connect(logFileReader, SIGNAL(contentChanged(LogFileReader *, Analyzer::ReadingMode, QStringList)),
+ this, SLOT(logFileChanged(LogFileReader *, Analyzer::ReadingMode, QStringList)));
+ connect(logFileReader, SIGNAL(statusBarChanged(QString)), this, SIGNAL(statusBarChanged(QString)));
+ connect(logFileReader, SIGNAL(errorOccured(QString, QString)), this,
+ SIGNAL(errorOccured(QString, QString)));
+ }
+}
+
+void FileAnalyzer::logFileChanged(LogFileReader *logFileReader, ReadingMode readingMode,
+ const QStringList &content)
+{
+ if (readingMode == Analyzer::FullRead)
+ logDebug() << "File " << logFileReader->logFile().url().path() << " has been modified on full read.";
+ else
+ logDebug() << "File " << logFileReader->logFile().url().path()
+ << " has been modified on partial read";
+
+ if (parsingPaused == true) {
+ logDebug() << "Pause enabled. Nothing read.";
+ return;
+ }
+
+ logDebug() << "Locking file modifications of " << logFileReader->logFile().url().path();
+ insertionLocking->lock();
+ logDebug() << "Unlocking file modifications of " << logFileReader->logFile().url().path();
+
+ QTime benchmark;
+ benchmark.start();
+
+ int insertedLogLineCount;
+
+ logViewModel->startingMultipleInsertions(readingMode);
+
+ if (readingMode == Analyzer::UpdatingRead) {
+ insertedLogLineCount = insertLines(content, logFileReader->logFile(), Analyzer::UpdatingRead);
+ } else {
+ logDebug() << "Reading file " << logFileReader->logFile().url().path();
+
+ emit statusBarChanged(i18n("Opening '%1'...", logFileReader->logFile().url().path()));
+
+ // Inform that we are now reading the "index" file
+ emit readFileStarted(*logMode, logFileReader->logFile(),
+ logFileReaders.count() - logFileReaders.indexOf(logFileReader),
+ logFileReaders.count());
+
+ insertedLogLineCount = insertLines(content, logFileReader->logFile(), Analyzer::FullRead);
+
+ emit statusBarChanged(
+ i18n("Log file '%1' loaded successfully.", logFileReader->logFile().url().path()));
+ }
+
+ logViewModel->endingMultipleInsertions(readingMode, insertedLogLineCount);
+
+ // Inform connected LoadingBar that the reading is now finished
+ emit readEnded();
+
+ // Inform LogManager that new lines have been added
+ emit logUpdated(insertedLogLineCount);
+
+ // Inform MainWindow status bar
+ emit statusBarChanged(i18n("Log file '%1' has changed.", logFileReader->logFile().url().path()));
+
+ logDebug() << "Updating log files in " << benchmark.elapsed() << " ms";
+
+ insertionLocking->unlock();
+}
+
+int FileAnalyzer::insertLines(const QStringList &bufferedLines, const LogFile &logFile, ReadingMode readingMode)
+{
+ logDebug() << "Inserting lines...";
+
+ // If there is no line
+ if (bufferedLines.size() == 0) {
+ logWarning() << "File is empty : " << logFile.url().path();
+ }
+
+ int stop = 0;
+ int currentPosition = 0;
+
+ QListIterator<QString> it(bufferedLines);
+ /**
+ * If the log file is sorted, then we can ignore the first lines
+ * if there are more lines in the log file than the max lines
+ *
+ * TODO Read revertly the file and ignore last lines if we are in Descending mode
+ */
+ logDebug() << "Log file Sort mode is " << logFileSortMode();
+ if (logFileSortMode() == Analyzer::AscendingSortedLogFile) {
+ // Calculate how many lines we will ignore
+ if (bufferedLines.size() > KSystemLogConfig::maxLines()) {
+ stop = bufferedLines.size() - KSystemLogConfig::maxLines();
+ }
+
+ // Ignore those lines
+ while (currentPosition < stop) {
+ it.next();
+ ++currentPosition;
+ }
+ }
+
+ int insertedLogLineCount = 0;
+ while (currentPosition < bufferedLines.size()) {
+ QString buffer(it.next());
+
+ bool inserted = insertLine(buffer, logFile, readingMode);
+ if (inserted) {
+ insertedLogLineCount++;
+ }
+
+ if (readingMode == Analyzer::FullRead) {
+ informOpeningProgress(currentPosition, (bufferedLines.size() - 1) - stop);
+ }
+
+ ++currentPosition;
+ }
+
+ logDebug() << "Total read lines :" << (bufferedLines.size() - stop) << "(" << logFile.url().path() << ")";
+
+ return insertedLogLineCount;
+}
+
+bool FileAnalyzer::insertLine(const QString &buffer, const LogFile &originalFile, ReadingMode readingMode)
+{
+ LogLine *line = parseMessage(buffer, originalFile);
+
+ // Invalid log line
+ if (line == NULL) {
+ return false;
+ }
+
+ // On full reading, it is not needed to display the recent status
+ if (readingMode == Analyzer::FullRead) {
+ line->setRecent(false);
+ }
+
+ return logViewModel->insertNewLogLine(line);
+}
+
+inline void FileAnalyzer::informOpeningProgress(int currentPosition, int total)
+{
+ int each = total / 100;
+ if (each == 0) {
+ return;
+ }
+
+ if (currentPosition % each == 0) {
+ emit openingProgressed();
+ }
+}
diff --git a/src/lib/fileAnalyzer.h b/src/lib/fileAnalyzer.h
new file mode 100644
index 0000000..f876083
--- /dev/null
+++ b/src/lib/fileAnalyzer.h
@@ -0,0 +1,88 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef _FILEANALYZER_H_
+#define _FILEANALYZER_H_
+
+#include <QList>
+#include <QMutex>
+#include <QString>
+#include <QStringList>
+
+#include "globals.h"
+
+#include "logLine.h"
+
+#include "logFile.h"
+#include "logViewColumn.h"
+#include "logViewColumns.h"
+
+#include "analyzer.h"
+
+class LogViewModel;
+class LogFileReader;
+class LogMode;
+
+class FileAnalyzer : public Analyzer
+{
+ Q_OBJECT
+
+public:
+ explicit FileAnalyzer(LogMode *logMode);
+
+ virtual ~FileAnalyzer();
+
+ virtual void watchLogFiles(bool enabled);
+
+ virtual void setLogFiles(const QList<LogFile> &logFiles);
+
+protected:
+ virtual LogFileReader *createLogFileReader(const LogFile &logFile) = 0;
+ virtual Analyzer::LogFileSortMode logFileSortMode() = 0;
+
+ virtual LogLine *parseMessage(const QString &logLine, const LogFile &originalFile) = 0;
+
+private:
+ inline void informOpeningProgress(int currentPosition, int total);
+
+ void deleteLogFiles();
+
+ /**
+ * Parse and insert the buffered lines in the model
+ * Returns the count of inserted lines
+ */
+ int insertLines(const QStringList &bufferedLines, const LogFile &logFile, ReadingMode readingMode);
+
+ /**
+ * Parse and insert a line in the model
+ * Returns false if it was not inserted, true if it was
+ */
+ bool insertLine(const QString &buffer, const LogFile &originalFile, ReadingMode readingMode);
+
+private slots:
+ void logFileChanged(LogFileReader *logFileReader, Analyzer::ReadingMode readingMode,
+ const QStringList &content);
+
+protected:
+ QList<LogFileReader *> logFileReaders;
+};
+
+#endif // _FILEANALYZER_H_
diff --git a/src/logModePluginsLoader.cpp b/src/logModePluginsLoader.cpp
index e09b55d..5370191 100644
--- a/src/logModePluginsLoader.cpp
+++ b/src/logModePluginsLoader.cpp
@@ -42,6 +42,7 @@
#include "acpidFactory.h"
#include "xsessionFactory.h"
#include "sambaFactory.h"
+#include "journaldFactory.h"
LogModePluginsLoader::LogModePluginsLoader(QWidget *parent)
: parent(parent)
@@ -92,4 +93,7 @@ void LogModePluginsLoader::loadPlugins()
// XSession
Globals::instance()->registerLogModeFactory(new XSessionLogModeFactory());
+
+ // Journald
+ Globals::instance()->registerLogModeFactory(new JournaldModeFactory());
}
diff --git a/src/modes/acpid/acpidAnalyzer.h b/src/modes/acpid/acpidAnalyzer.h
index e8f888d..81cf483 100644
--- a/src/modes/acpid/acpidAnalyzer.h
+++ b/src/modes/acpid/acpidAnalyzer.h
@@ -24,19 +24,19 @@
#include <KLocalizedString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "localLogFileReader.h"
#include "parsingHelper.h"
#include "acpidLogMode.h"
-class AcpidAnalyzer : public Analyzer
+class AcpidAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
AcpidAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
{
}
diff --git a/src/modes/apache/apacheAccessAnalyzer.h b/src/modes/apache/apacheAccessAnalyzer.h
index 15fe2bf..0edd44b 100644
--- a/src/modes/apache/apacheAccessAnalyzer.h
+++ b/src/modes/apache/apacheAccessAnalyzer.h
@@ -24,7 +24,7 @@
#include <KLocalizedString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "localLogFileReader.h"
#include "logging.h"
@@ -32,13 +32,13 @@
#include "apacheAccessLogMode.h"
-class ApacheAccessAnalyzer : public Analyzer
+class ApacheAccessAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
explicit ApacheAccessAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
{
}
diff --git a/src/modes/apache/apacheAnalyzer.h b/src/modes/apache/apacheAnalyzer.h
index b45a2e2..47f3188 100644
--- a/src/modes/apache/apacheAnalyzer.h
+++ b/src/modes/apache/apacheAnalyzer.h
@@ -24,7 +24,7 @@
#include <KLocalizedString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "logging.h"
@@ -32,13 +32,13 @@
#include "apacheLogMode.h"
#include "parsingHelper.h"
-class ApacheAnalyzer : public Analyzer
+class ApacheAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
explicit ApacheAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
{
initializeTypeLevels();
}
diff --git a/src/modes/base/syslogAnalyzer.cpp b/src/modes/base/syslogAnalyzer.cpp
index afa588b..45b7c04 100644
--- a/src/modes/base/syslogAnalyzer.cpp
+++ b/src/modes/base/syslogAnalyzer.cpp
@@ -42,7 +42,7 @@
#include "ksystemlogConfig.h"
SyslogAnalyzer::SyslogAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
{
}
diff --git a/src/modes/base/syslogAnalyzer.h b/src/modes/base/syslogAnalyzer.h
index a668c1a..8d28c03 100644
--- a/src/modes/base/syslogAnalyzer.h
+++ b/src/modes/base/syslogAnalyzer.h
@@ -24,7 +24,7 @@
#include <QString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "logFile.h"
@@ -33,7 +33,7 @@ class LogFileReader;
class LogMode;
class LogLine;
-class SyslogAnalyzer : public Analyzer
+class SyslogAnalyzer : public FileAnalyzer
{
Q_OBJECT
diff --git a/src/modes/cups/cupsAccessAnalyzer.h b/src/modes/cups/cupsAccessAnalyzer.h
index 4783835..e12f204 100644
--- a/src/modes/cups/cupsAccessAnalyzer.h
+++ b/src/modes/cups/cupsAccessAnalyzer.h
@@ -24,7 +24,7 @@
#include <KLocalizedString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "localLogFileReader.h"
#include "logging.h"
@@ -32,13 +32,13 @@
#include "cupsAccessLogMode.h"
-class CupsAccessAnalyzer : public Analyzer
+class CupsAccessAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
explicit CupsAccessAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
, cupsAccessRegex(
QLatin1String("(\\S*) (\\S*) (\\S*) \\[(.*)\\] \"(.*)\" (\\S*) (\\S*) (\\S*) (\\S*)"))
{
diff --git a/src/modes/cups/cupsAnalyzer.h b/src/modes/cups/cupsAnalyzer.h
index c387a6e..4c5a96a 100644
--- a/src/modes/cups/cupsAnalyzer.h
+++ b/src/modes/cups/cupsAnalyzer.h
@@ -24,7 +24,7 @@
#include <KLocalizedString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "logging.h"
@@ -34,13 +34,13 @@
#define DEBUG2_LOG_LEVEL_ICON "source"
-class CupsAnalyzer : public Analyzer
+class CupsAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
explicit CupsAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
{
initializeTypeLevels();
}
diff --git a/src/modes/cups/cupsPageAnalyzer.h b/src/modes/cups/cupsPageAnalyzer.h
index 634ddcc..a2c5624 100644
--- a/src/modes/cups/cupsPageAnalyzer.h
+++ b/src/modes/cups/cupsPageAnalyzer.h
@@ -24,7 +24,7 @@
#include <KLocalizedString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "localLogFileReader.h"
#include "logging.h"
@@ -32,13 +32,13 @@
#include "cupsPageLogMode.h"
-class CupsPageAnalyzer : public Analyzer
+class CupsPageAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
explicit CupsPageAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
, cupsPageRegex(QLatin1String("(\\S*) (\\S*) (\\S*) \\[(.*)\\] (\\S*) (\\S*) (\\S*)"))
{
}
diff --git a/src/modes/cups/cupsPdfAnalyzer.h b/src/modes/cups/cupsPdfAnalyzer.h
index 6a1e6a4..e8867bb 100644
--- a/src/modes/cups/cupsPdfAnalyzer.h
+++ b/src/modes/cups/cupsPdfAnalyzer.h
@@ -24,7 +24,7 @@
#include <KLocalizedString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "localLogFileReader.h"
#include "logging.h"
@@ -32,14 +32,14 @@
#include "cupsPdfLogMode.h"
-class CupsPdfAnalyzer : public Analyzer
+class CupsPdfAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
// Fri Sep 30 21:58:37 2005 [ERROR] failed to create spool directory (/var/spool/cups-pdf/SPOOL)
explicit CupsPdfAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
, cupsPdfRegex(QLatin1String("\\S* ") + ParsingHelper::instance()->syslogDateTimeRegexp()
+ QLatin1String("[ ]+\\[(\\w*)\\][ ]+(.*)"))
{ // \\[(.*)\\] (\\S*) (\\S*) (\\S*)
diff --git a/src/modes/journald/CMakeLists.txt b/src/modes/journald/CMakeLists.txt
new file mode 100644
index 0000000..e73794a
--- /dev/null
+++ b/src/modes/journald/CMakeLists.txt
@@ -0,0 +1,35 @@
+
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}/../..
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../lib
+ ${CMAKE_CURRENT_BINARY_DIR}/../../config
+ ${CMAKE_CURRENT_SOURCE_DIR}/../base
+ ${CMAKE_CURRENT_BINARY_DIR}/../base
+)
+
+set(ksystemlog_journald_sources
+ journaldLogMode.cpp
+ journaldConfiguration.cpp
+ journaldConfigurationWidget.cpp
+ journaldFactory.cpp
+ journaldAnalyzer.cpp
+)
+
+ki18n_wrap_ui(ksystemlog_journald_sources journaldConfigurationWidget.ui )
+
+add_library(ksystemlog_journald STATIC ${ksystemlog_journald_sources})
+
+add_dependencies(
+ ksystemlog_journald
+
+ ksystemlog_base_mode
+ ksystemlog_lib
+)
+
+target_link_libraries(
+ ksystemlog_journald
+
+ ksystemlog_lib
+ ksystemlog_base_mode
+ ksystemlog_config
+)
diff --git a/src/modes/journald/journaldAnalyzer.cpp b/src/modes/journald/journaldAnalyzer.cpp
new file mode 100644
index 0000000..1cf7c72
--- /dev/null
+++ b/src/modes/journald/journaldAnalyzer.cpp
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include "journaldAnalyzer.h"
+
+//#include <QStringList>
+//#include <QDateTime>
+
+#include <KLocalizedString>
+
+//#include "globals.h"
+//#include "logging.h"
+
+//#include "logLine.h"
+//#include "logMode.h"
+//#include "logLevel.h"
+//#include "logViewWidget.h"
+
+//#include "logViewModel.h"
+
+//#include "parsingHelper.h"
+
+//#include "ksystemlogConfig.h"
+
+JournaldAnalyzer::JournaldAnalyzer(LogMode *logMode)
+ : Analyzer(logMode)
+{
+}
+
+JournaldAnalyzer::~JournaldAnalyzer()
+{
+}
+
+LogViewColumns JournaldAnalyzer::initColumns()
+{
+ LogViewColumns columns;
+ columns.addColumn(LogViewColumn(i18n("Date"), true, true));
+ columns.addColumn(LogViewColumn(i18n("Unit"), true, true));
+ columns.addColumn(LogViewColumn(i18n("Message"), true, true));
+ return columns;
+}
+
+void JournaldAnalyzer::setLogFiles(const QList<LogFile> &logFiles)
+{
+}
+
+void JournaldAnalyzer::watchLogFiles(bool enabled)
+{
+}
diff --git a/src/modes/journald/journaldAnalyzer.h b/src/modes/journald/journaldAnalyzer.h
new file mode 100644
index 0000000..f9f0c07
--- /dev/null
+++ b/src/modes/journald/journaldAnalyzer.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef _JOURNALD_ANALYZER_H_
+#define _JOURNALD_ANALYZER_H_
+
+#include <QString>
+
+#include "analyzer.h"
+
+#include "logFile.h"
+
+class LogFileReader;
+
+class LogMode;
+class LogLine;
+
+class JournaldAnalyzer : public Analyzer
+{
+ Q_OBJECT
+
+public:
+ explicit JournaldAnalyzer(LogMode *logMode);
+
+ virtual ~JournaldAnalyzer();
+
+ virtual LogViewColumns initColumns();
+
+ virtual void setLogFiles(const QList<LogFile> &logFiles);
+
+ virtual void watchLogFiles(bool enabled);
+};
+
+#endif // _JOURNALD_ANALYZER_H_
diff --git a/src/modes/journald/journaldConfiguration.cpp b/src/modes/journald/journaldConfiguration.cpp
new file mode 100644
index 0000000..bc7b438
--- /dev/null
+++ b/src/modes/journald/journaldConfiguration.cpp
@@ -0,0 +1,22 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include "journaldConfiguration.h"
diff --git a/src/modes/journald/journaldConfiguration.h b/src/modes/journald/journaldConfiguration.h
new file mode 100644
index 0000000..72475a4
--- /dev/null
+++ b/src/modes/journald/journaldConfiguration.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef _JOURNALD_CONFIGURATION_H_
+#define _JOURNALD_CONFIGURATION_H_
+
+#include <QStringList>
+
+#include "logModeConfiguration.h"
+
+#include "logging.h"
+#include "defaults.h"
+
+#include "journaldLogMode.h"
+
+#include "ksystemlogConfig.h"
+
+class JournaldConfiguration : public LogModeConfiguration
+{
+ Q_OBJECT
+
+public:
+ JournaldConfiguration()
+// : d(new XSessionConfigurationPrivate())
+ {
+ configuration->setCurrentGroup(QLatin1String("JournaldLogMode"));
+ }
+
+ virtual ~JournaldConfiguration() {}
+
+private:
+};
+
+#endif // _JOURNALD_CONFIGURATION_H_
diff --git a/src/modes/journald/journaldConfigurationWidget.cpp b/src/modes/journald/journaldConfigurationWidget.cpp
new file mode 100644
index 0000000..6cca7de
--- /dev/null
+++ b/src/modes/journald/journaldConfigurationWidget.cpp
@@ -0,0 +1,22 @@
+/***************************************************************************
+ * KApacheLog, a apache log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include "journaldConfigurationWidget.h"
diff --git a/src/modes/journald/journaldConfigurationWidget.h b/src/modes/journald/journaldConfigurationWidget.h
new file mode 100644
index 0000000..e7669d3
--- /dev/null
+++ b/src/modes/journald/journaldConfigurationWidget.h
@@ -0,0 +1,92 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef _JOURNALD_CONFIGURATION_WIDGET_H_
+#define _JOURNALD_CONFIGURATION_WIDGET_H_
+
+#include <QGroupBox>
+#include <QCheckBox>
+
+#include <KLocalizedString>
+//#include <kurlrequester.h>
+
+#include "globals.h"
+#include "logging.h"
+#include "fileList.h"
+
+#include "logLevel.h"
+
+#include "journaldConfiguration.h"
+#include "journaldLogMode.h"
+
+#include "logModeConfigurationWidget.h"
+
+#include "ui_journaldConfigurationWidget.h"
+
+class JournaldConfigurationWidget : public LogModeConfigurationWidget, public Ui::JournaldConfigurationWidget
+{
+ Q_OBJECT
+
+public:
+ JournaldConfigurationWidget()
+ : LogModeConfigurationWidget(i18n("Journald Log"), QLatin1String(JOURNALD_MODE_ICON),
+ i18n("Journald Log"))
+ {
+ setupUi(this);
+ }
+
+ ~JournaldConfigurationWidget() {}
+
+public slots:
+
+ void saveConfig()
+ {
+ JournaldConfiguration *configuration = Globals::instance()
+ ->findLogMode(QLatin1String(JOURNALD_LOG_MODE_ID))
+ ->logModeConfiguration<JournaldConfiguration *>();
+ }
+
+ void readConfig()
+ {
+ JournaldConfiguration *configuration = Globals::instance()
+ ->findLogMode(QLatin1String(JOURNALD_LOG_MODE_ID))
+ ->logModeConfiguration<JournaldConfiguration *>();
+ }
+
+ void defaultConfig()
+ {
+ // TODO Find a way to read the configuration per default
+ readConfig();
+ }
+
+protected:
+ bool isValid() const
+ {
+ return true;
+ // if (journaldUrlRequester->url().path().isEmpty() == false) {
+ // return true;
+ // }
+
+ // return false;
+ }
+};
+
+#endif // _JOURNALD_CONFIGURATION_WIDGET_H_
diff --git a/src/modes/journald/journaldConfigurationWidget.ui b/src/modes/journald/journaldConfigurationWidget.ui
new file mode 100644
index 0000000..cc5a563
--- /dev/null
+++ b/src/modes/journald/journaldConfigurationWidget.ui
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>JournaldConfigurationWidget</class>
+ <widget class="QWidget" name="JournaldConfigurationWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Journald options</string>
+ </property>
+ <layout class="QGridLayout"/>
+ </widget>
+ </item>
+ <item>
+ <spacer name="bottomSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/modes/journald/journaldFactory.cpp b/src/modes/journald/journaldFactory.cpp
new file mode 100644
index 0000000..7be1c3f
--- /dev/null
+++ b/src/modes/journald/journaldFactory.cpp
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include "journaldFactory.h"
+
+#include <QList>
+
+#include "logMode.h"
+#include "logging.h"
+
+#include "simpleAction.h"
+#include "journaldLogMode.h"
+
+#include "logModeFactory.h"
+
+QList<LogMode *> JournaldModeFactory::createLogModes() const
+{
+ QList<LogMode *> logModes;
+ logModes.append(new JournaldLogMode());
+ return logModes;
+}
+
+LogModeAction *JournaldModeFactory::createLogModeAction() const
+{
+ LogMode *logMode = Globals::instance()->findLogMode(QLatin1String(JOURNALD_LOG_MODE_ID));
+ SimpleAction *logModeAction = new SimpleAction(logMode->action(), logMode);
+
+ return logModeAction;
+}
diff --git a/src/modes/journald/journaldFactory.h b/src/modes/journald/journaldFactory.h
new file mode 100644
index 0000000..ea0afa4
--- /dev/null
+++ b/src/modes/journald/journaldFactory.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef _JOURNALD_FACTORY_H_
+#define _JOURNALD_FACTORY_H_
+
+#include <QList>
+
+#include "logModeFactory.h"
+
+class LogModeAction;
+class LogMode;
+
+class JournaldModeFactory : public LogModeFactory
+{
+ Q_OBJECT
+
+public:
+ QList<LogMode *> createLogModes() const;
+
+ LogModeAction *createLogModeAction() const;
+};
+
+#endif // _JOURNALD_FACTORY_H_
diff --git a/src/modes/journald/journaldLogMode.cpp b/src/modes/journald/journaldLogMode.cpp
new file mode 100644
index 0000000..05aa084
--- /dev/null
+++ b/src/modes/journald/journaldLogMode.cpp
@@ -0,0 +1,66 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include "journaldLogMode.h"
+
+#include <QList>
+
+#include <KLocalizedString>
+
+#include "logging.h"
+#include "logMode.h"
+
+#include "journaldAnalyzer.h"
+#include "journaldConfigurationWidget.h"
+#include "journaldConfiguration.h"
+
+#include "logModeItemBuilder.h"
+
+JournaldLogMode::JournaldLogMode()
+ : LogMode(QLatin1String(JOURNALD_LOG_MODE_ID), i18n("Journald Log"), QLatin1String(JOURNALD_MODE_ICON))
+{
+ d->logModeConfiguration = new JournaldConfiguration();
+
+ d->logModeConfigurationWidget = new JournaldConfigurationWidget();
+
+ d->itemBuilder = new LogModeItemBuilder();
+
+ d->action = createDefaultAction();
+ d->action->setToolTip(i18n("Display the Journald log."));
+ d->action->setWhatsThis(i18n(
+ "Displays the system log in the current tab. This log is generally used by non-specialized processes "
+ "(like \"sudo\" or \"fsck\" commands)"));
+}
+
+JournaldLogMode::~JournaldLogMode()
+{
+}
+
+Analyzer *JournaldLogMode::createAnalyzer()
+{
+ return new JournaldAnalyzer(this);
+}
+
+QList<LogFile> JournaldLogMode::createLogFiles()
+{
+ // No log file for journald.
+ return QList<LogFile>();
+}
diff --git a/src/modes/journald/journaldLogMode.h b/src/modes/journald/journaldLogMode.h
new file mode 100644
index 0000000..670fc35
--- /dev/null
+++ b/src/modes/journald/journaldLogMode.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * KSystemLog, a system log viewer tool *
+ * Copyright (C) 2007 by Nicolas Ternisien *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef _JOURNALD_LOG_MODE_H_
+#define _JOURNALD_LOG_MODE_H_
+
+/**
+ * Journald Log Mode Identifier
+ */
+#define JOURNALD_LOG_MODE_ID "journaldLogMode"
+
+/**
+ * System Log Icon
+ */
+#define JOURNALD_MODE_ICON "computer"
+
+#include <QList>
+
+#include "logFile.h"
+#include "logMode.h"
+
+class JournaldLogMode : public LogMode
+{
+ Q_OBJECT
+
+public:
+ explicit JournaldLogMode();
+
+ ~JournaldLogMode();
+
+ Analyzer *createAnalyzer();
+
+ QList<LogFile> createLogFiles();
+};
+
+#endif // _JOURNALD_LOG_MODE_H_
diff --git a/src/modes/kernel/kernelAnalyzer.h b/src/modes/kernel/kernelAnalyzer.h
index 120ad8f..df1671b 100644
--- a/src/modes/kernel/kernelAnalyzer.h
+++ b/src/modes/kernel/kernelAnalyzer.h
@@ -29,7 +29,7 @@
#include "logging.h"
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "localLogFileReader.h"
#include "processOutputLogFileReader.h"
@@ -37,13 +37,13 @@
class LogMode;
-class KernelAnalyzer : public Analyzer
+class KernelAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
KernelAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
{
startupTime();
}
diff --git a/src/modes/samba/sambaAnalyzer.h b/src/modes/samba/sambaAnalyzer.h
index d14313c..b0d9e2d 100644
--- a/src/modes/samba/sambaAnalyzer.h
+++ b/src/modes/samba/sambaAnalyzer.h
@@ -24,7 +24,7 @@
#include <KLocalizedString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "logging.h"
@@ -32,13 +32,13 @@
#include "sambaLogMode.h"
#include "parsingHelper.h"
-class SambaAnalyzer : public Analyzer
+class SambaAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
explicit SambaAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
{
currentLogLine = NULL;
}
diff --git a/src/modes/xorg/xorgAnalyzer.h b/src/modes/xorg/xorgAnalyzer.h
index 5328a1a..6e4ed29 100644
--- a/src/modes/xorg/xorgAnalyzer.h
+++ b/src/modes/xorg/xorgAnalyzer.h
@@ -24,7 +24,7 @@
#include <KLocalizedString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "localLogFileReader.h"
#include "parsingHelper.h"
@@ -36,13 +36,13 @@
#define PROBED_LOG_LEVEL_ICON "favorites"
#define NOT_IMPLEMENTED_LOG_LEVEL_ICON "document-new"
-class XorgAnalyzer : public Analyzer
+class XorgAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
XorgAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
, currentDateTime(QDateTime::currentDateTime())
{
initializeTypeName();
diff --git a/src/modes/xsession/xsessionAnalyzer.h b/src/modes/xsession/xsessionAnalyzer.h
index a60992f..13b1607 100644
--- a/src/modes/xsession/xsessionAnalyzer.h
+++ b/src/modes/xsession/xsessionAnalyzer.h
@@ -24,7 +24,7 @@
#include <KLocalizedString>
-#include "analyzer.h"
+#include "fileAnalyzer.h"
#include "localLogFileReader.h"
#include "parsingHelper.h"
@@ -32,13 +32,13 @@
#include "xsessionLogMode.h"
#include "xsessionConfiguration.h"
-class XSessionAnalyzer : public Analyzer
+class XSessionAnalyzer : public FileAnalyzer
{
Q_OBJECT
public:
XSessionAnalyzer(LogMode *logMode)
- : Analyzer(logMode)
+ : FileAnalyzer(logMode)
, currentDateTime(QDateTime::currentDateTime())
{
}