Debian Codegraph @

include/dloghelper.h

raw
1 // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4
5 #ifndef DLOGHELPER_H
6 #define DLOGHELPER_H
7
8 #include <dlog_global.h>
9 #include "Logger.h"
10
11 #include <QString>
12 #include <QDebug>
13
14 DLOG_CORE_BEGIN_NAMESPACE
15 class DLogHelperPrivate;
16 class LIBDLOG_SHARED_EXPORT DLogHelper : public QObject
17 {
18 Q_DISABLE_COPY(DLogHelper)
19 public:
20 DLogHelper(Logger::LogLevel level, const QMessageLogContext &context, QObject *parent = nullptr);
21 ~DLogHelper();
22
23 void write(const char *msg, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
24 void write(const QString &msg);
25 QDebug write();
26
27 void timing(const QString &msg, QObject *context = nullptr);
28
29 static Logger::LogLevel levelFromQtMsgType(QtMsgType mt);
30 static QtMsgType qtMsgTypeFromLogLevel(Logger::LogLevel lvl);
31
32 Q_DECLARE_PRIVATE(DLogHelper)
33 };
34
35 DLOG_CORE_END_NAMESPACE
36
37 #endif // DLOGHELPER_H