1 /*
2  *  Copyright (c) 2019 Boudewijn Rempt <boud@valdyas.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 #ifndef KISUSAGELOGGER_H
19 #define KISUSAGELOGGER_H
20 
21 #include <QString>
22 #include <QScopedPointer>
23 
24 #include "kritaglobal_export.h"
25 
26 /**
27  * @brief The KisUsageLogger class logs messages to a logfile
28  */
29 class KRITAGLOBAL_EXPORT KisUsageLogger
30 {
31 
32 public:
33 
34     KisUsageLogger();
35     ~KisUsageLogger();
36 
37     static void initialize();
38     static void close();
39 
40     /// basic system information
41     ///    (there is other information spreaded in the code
42     ///     check usages of writeSysInfo for details)
43     static QString basicSystemInfo();
44 
45     /// Logs with date/time
46     static void log(const QString &message);
47 
48     /// Writes without date/time
49     static void write(const QString &message);
50 
51     /// Writes to the system information file and Krita log
52     static void writeSysInfo(const QString &message);
53 
54     static void writeHeader();
55 
56     /// Returns information about all available screens
57     static QString screenInformation();
58 
59 private:
60 
61     void rotateLog();
62 
63     Q_DISABLE_COPY(KisUsageLogger)
64 
65     struct Private;
66     const QScopedPointer<Private> d;
67 
68     static const QString s_sectionHeader;
69     static const int s_maxLogs {10};
70 
71 };
72 
73 #endif // KISUSAGELOGGER_H
74