1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef FRAMEWORKLOG_H
6#define FRAMEWORKLOG_H
7
8#include "framework/log/codetimecheck.h"
9
10#include "framework/framework_global.h"
11
12#include <QDebug>
13#include <QLoggingCategory>
14
15#ifdef DTK_LOG
16#define dpfDebug() qDebug() << "Framework:"
17#define dpfInfo() qInfo() << "Framework:"
18#define dpfWarning() qWarning() << "Framework:"
19#define dpfCritical() qCritical() << "Framework:"
20#else
21/**
22 * @brief Framework 可进行相关调用,如下
23 * @code
24 * qCDebug(Framework) << "hello"; //调试信息打印
25 * qCInfo(Framework) << "hello"; //信息打印
26 * qCDWarning(Framework) << "hello"; //警告打印
27 * qCCritical(Framework) << "hello"; //关键日志打印
28 * @endcode
29 */
30Q_DECLARE_LOGGING_CATEGORY(Framework)
31
32/**
33 * @brief FrameworkLog 宏函数,可进行相关打印调用,如下
34 * @code
35 * dpfDebug() << "hello"; //调试信息打印
36 * dpfInfo() << "hello"; //信息打印
37 * dpfWarning() << "hello"; //警告打印
38 * dpfCritical() << "hello"; //关键日志打印
39 * @endcode
40 */
41#define dpfDebug() qCDebug(Framework)
42#define dpfInfo() qCInfo(Framework)
43#define dpfWarning() qCDWarning(Framework)
44#define dpfCritical() qCCritical(Framework)
45#endif
46
47DPF_BEGIN_NAMESPACE
48
49/**
50 * @brief The FrameworkLog class
51 * 框架日志打印模块,内部封装输出重定向与日志格式化
52 */
53class FrameworkLog final
54{
55public:
56 explicit FrameworkLog() = delete;
57 static void enableFrameworkLog(bool enabled = true);
58 static void setLogCacheDayCount(uint dayCount);
59 static uint logCacheDayCount();
60 static void initialize();
61};
62
63DPF_END_NAMESPACE
64
65#endif // FRAMEWORKLOG_H
66