1 /*
2     SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "apacheAccessLogMode.h"
8 
9 #include <QAction>
10 
11 #include <KLocalizedString>
12 
13 #include "ksystemlog_debug.h"
14 
15 #include "apacheAccessAnalyzer.h"
16 #include "apacheAccessItemBuilder.h"
17 #include "apacheConfiguration.h"
18 #include "apacheConfigurationWidget.h"
19 
ApacheAccessLogMode(QSharedPointer<ApacheConfiguration> & apacheConfiguration,ApacheConfigurationWidget * apacheConfigurationWidget)20 ApacheAccessLogMode::ApacheAccessLogMode(QSharedPointer<ApacheConfiguration> &apacheConfiguration, ApacheConfigurationWidget *apacheConfigurationWidget)
21     : LogMode(QStringLiteral(APACHE_ACCESS_LOG_MODE_ID), i18n("Apache Access Log"), QStringLiteral(APACHE_ACCESS_MODE_ICON))
22 {
23     d->logModeConfiguration = apacheConfiguration;
24     d->logModeConfigurationWidget = apacheConfigurationWidget;
25 
26     d->itemBuilder = new ApacheAccessItemBuilder();
27 
28     // Apache Log Action
29     d->action = createDefaultAction();
30     d->action->setToolTip(i18n("Display the Apache Access log."));
31     d->action->setWhatsThis(
32         i18n("Displays the Apache Access log in the current tab. Apache is the main used Web server in the world. "
33              "This log saves all requests performed by the Apache web server."));
34 
35     checkLogFilesPresence(apacheConfiguration->apacheAccessPaths());
36 }
37 
~ApacheAccessLogMode()38 ApacheAccessLogMode::~ApacheAccessLogMode()
39 {
40 }
41 
createAnalyzer(const QVariant & options)42 Analyzer *ApacheAccessLogMode::createAnalyzer(const QVariant &options)
43 {
44     Q_UNUSED(options)
45     return new ApacheAccessAnalyzer(this);
46 }
47 
createLogFiles()48 QVector<LogFile> ApacheAccessLogMode::createLogFiles()
49 {
50     auto *apacheConfiguration = logModeConfiguration<ApacheConfiguration *>();
51     return apacheConfiguration->findNoModeLogFiles(apacheConfiguration->apacheAccessPaths());
52 }
53