swift
Loading...
Searching...
No Matches
filelogger.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_FILELOGGER_H
7#define SWIFT_MISC_FILELOGGER_H
8
9#include <QFile>
10#include <QObject>
11#include <QString>
12#include <QTextStream>
13
14#include "misc/logpattern.h"
15#include "misc/statusmessage.h"
17
18namespace swift::misc
19{
22 {
24
25 public:
28 CFileLogger(QObject *parent = nullptr);
29
31 ~CFileLogger() override;
32
34 void changeLogPattern(const CLogPattern &pattern) { m_logPattern = pattern; }
35
37 void close();
38
40 static QString getLogFileName();
41
43 static QString getLogFilePath();
44
45 public slots:
47 void writeStatusMessageToFile(const swift::misc::CStatusMessage &statusMessage);
48
49 private:
50 void removeOldLogFiles();
51 void writeHeaderToFile();
52 void writeContentToFile(const QString &content);
53
54 CLogPattern m_logPattern;
55 QFile m_logFile;
56 QString m_fileName;
57 QTextStream m_stream;
58 QString m_previousCategories;
59 };
60} // namespace swift::misc
61
62#endif // SWIFT_MISC_FILELOGGER_H
void changeLogPattern(const CLogPattern &pattern)
Change the log pattern. Default is to log all messages.
Definition filelogger.h:34
CFileLogger(QObject *parent=nullptr)
Constructor. Filename defaults to QCoreApplication::applicationName() and path to "....
Value class for matching log messages based on their categories.
Definition logpattern.h:49
Streamable status message, e.g.
Free functions in swift::misc.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const
#define SWIFT_MISC_EXPORT
Export a class or function from the library.