File: dloghelper.h

package info (click to toggle)
dtklog 0.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 372 kB
  • sloc: cpp: 1,683; ansic: 59; makefile: 9
file content (37 lines) | stat: -rw-r--r-- 927 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-2.1-or-later

#ifndef DLOGHELPER_H
#define DLOGHELPER_H

#include <dlog_global.h>
#include "Logger.h"

#include <QString>
#include <QDebug>

DLOG_CORE_BEGIN_NAMESPACE
class DLogHelperPrivate;
class LIBDLOG_SHARED_EXPORT DLogHelper : public QObject
{
    Q_DISABLE_COPY(DLogHelper)
public:
    DLogHelper(Logger::LogLevel level, const QMessageLogContext &context, QObject *parent = nullptr);
    ~DLogHelper();

    void write(const char *msg, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
    void write(const QString &msg);
    QDebug write();

    void timing(const QString &msg, QObject *context = nullptr);

    static Logger::LogLevel levelFromQtMsgType(QtMsgType mt);
    static QtMsgType qtMsgTypeFromLogLevel(Logger::LogLevel lvl);

    Q_DECLARE_PRIVATE(DLogHelper)
};

DLOG_CORE_END_NAMESPACE

#endif // DLOGHELPER_H