1 /* 2 SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #pragma once 8 9 #include <QFile> 10 #include <QRegExp> 11 12 #include <KLocalizedString> 13 14 #include "ksystemlog_debug.h" 15 16 #include "fileAnalyzer.h" 17 18 #include "kernelLogMode.h" 19 #include "localLogFileReader.h" 20 #include "processOutputLogFileReader.h" 21 22 class LogMode; 23 24 class KernelAnalyzer : public FileAnalyzer 25 { 26 Q_OBJECT 27 28 public: 29 explicit KernelAnalyzer(LogMode *logMode); 30 ~KernelAnalyzer()31 ~KernelAnalyzer() override 32 { 33 } 34 35 LogViewColumns initColumns() override; 36 37 protected: 38 LogFileReader *createLogFileReader(const LogFile &logFile) override; 39 logFileSortMode()40 Analyzer::LogFileSortMode logFileSortMode() override 41 { 42 return Analyzer::AscendingSortedLogFile; 43 } 44 45 void startupTime(); 46 47 LogLine *parseMessage(const QString &logLine, const LogFile &originalLogFile) override; 48 parseComponentMessage(const QString & logLine,QStringList & messages)49 inline void parseComponentMessage(const QString &logLine, QStringList &messages) 50 { 51 QString message(logLine); 52 QString component; 53 54 int doublePointPosition = message.indexOf(QLatin1Char(':')); 55 56 // Estimate the max size of a component 57 if (doublePointPosition != -1 && doublePointPosition < 20) { 58 component = message.left(doublePointPosition); 59 // Remove component length + ": " 60 message.remove(0, doublePointPosition + 2); 61 } 62 63 messages.append(component); 64 messages.append(message.simplified()); 65 } 66 67 protected: 68 QDateTime mStartupDateTime; 69 }; 70 71