Debian Codegraph @

src/ApvlvLog.h

raw
1 /*
2 * This file is part of the apvlv package
3 * Copyright (C) <2024> Alf
4 *
5 * Contact: Alf <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22 /* @CPPFILE ApvlvLog.h
23 *
24 * Author: Alf <[email protected]>
25 */
26 #ifndef _APVLV_LOG_H_
27 #define _APVLV_LOG_H_
28
29 #include <QFile>
30 #include <QTextStream>
31 #include <QtMessageHandler>
32 #include <memory>
33 #include <mutex>
34
35 namespace apvlv
36 {
37
38 class ApvlvLog final
39 {
40 public:
41 ApvlvLog (const ApvlvLog &) = delete;
42 const ApvlvLog &operator= (const ApvlvLog &) = delete;
43 void setLogFile (const std::string &path);
44 ~ApvlvLog ();
45
46 static ApvlvLog *instance ();
47 static void logMessage (QtMsgType type, const QMessageLogContext &context,
48 const QString &msg);
49
50 private:
51 ApvlvLog () = default;
52 void writeMessage (const QString &log);
53
54 QFile mFile;
55 QTextStream mTextStream;
56 std::mutex mMutex;
57 };
58
59 };
60
61 #endif
62
63 /* Local Variables: */
64 /* mode: c++ */
65 /* End: */