File indexing completed on 2024-05-19 05:49:15
0001 /* 0002 SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <KLocalizedString> 0010 0011 #include "fileAnalyzer.h" 0012 0013 #include "ksystemlog_debug.h" 0014 #include "localLogFileReader.h" 0015 #include "parsingHelper.h" 0016 0017 #include "cupsAccessLogMode.h" 0018 #include <QRegExp> 0019 class CupsAccessAnalyzer : public FileAnalyzer 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 explicit CupsAccessAnalyzer(LogMode *logMode); 0025 0026 ~CupsAccessAnalyzer() override 0027 { 0028 } 0029 0030 LogViewColumns initColumns() override; 0031 0032 protected: 0033 const QRegExp mCupsAccessRegex; 0034 0035 LogFileReader *createLogFileReader(const LogFile &logFile) override; 0036 0037 Analyzer::LogFileSortMode logFileSortMode() override; 0038 0039 /* 0040 * https://www.cups.org/doc/man-cupsd-logs.html 0041 * 0042 * host group user date-time \"method resource version\" status bytes ipp-operation ipp-status 0043 * 10.0.1.2 - - [01/Dec/2005:21:50:28 +0000] "POST / HTTP/1.1" 200 317 CUPS-Get-Printers 0044 *successful-ok-ignored-or-substituted-attributes 0045 * localhost - - [01/Dec/2005:21:50:32 +0000] "GET /admin HTTP/1.1" 200 0 - - 0046 * localhost - - [01/Dec/2005:21:50:32 +0000] "POST / HTTP/1.1" 200 157 CUPS-Get-Printers 0047 *successful-ok-ignored-or-substituted-attributes 0048 * localhost - - [01/Dec/2005:21:50:32 +0000] "POST / HTTP/1.1" 200 1411 CUPS-Get-Devices - 0049 * localhost - - [01/Dec/2005:21:50:32 +0000] "GET /admin HTTP/1.1" 200 6667 - - 0050 * 0051 */ 0052 LogLine *parseMessage(const QString &logLine, const LogFile &originalLogFile) override; 0053 0054 inline LogLevel *findLevel(const QString &status) const 0055 { 0056 if (status == QLatin1String("successful-ok")) { 0057 return Globals::instance().informationLogLevel(); 0058 } else if (status == QLatin1String("ignored")) { 0059 return Globals::instance().warningLogLevel(); 0060 } 0061 0062 return Globals::instance().noticeLogLevel(); 0063 } 0064 };