| 1 |
// Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. |
| 2 |
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. |
| 3 |
// |
| 4 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 5 |
|
| 6 |
#ifndef LOGMANAGER_H |
| 7 |
#define LOGMANAGER_H |
| 8 |
|
| 9 |
#include <QScopedPointer> |
| 10 |
|
| 11 |
#include "dtkcore_global.h" |
| 12 |
|
| 13 |
DCORE_BEGIN_NAMESPACE |
| 14 |
|
| 15 |
class DLogManagerPrivate; |
| 16 |
class LIBDTKCORESHARED_EXPORT DLogManager |
| 17 |
{ |
| 18 |
Q_DISABLE_COPY(DLogManager) |
| 19 |
public: |
| 20 |
static void registerConsoleAppender(); |
| 21 |
static void registerFileAppender(); |
| 22 |
static void registerJournalAppender(); |
| 23 |
|
| 24 |
static QString getlogFilePath(); |
| 25 |
|
| 26 |
/*! |
| 27 |
* \brief setlogFilePath will change log file path of registerFileAppender |
| 28 |
* \a logFilePath is the full path of file appender log |
| 29 |
*/ |
| 30 |
static void setlogFilePath(const QString &logFilePath); |
| 31 |
|
| 32 |
static void setLogFormat(const QString &format); |
| 33 |
|
| 34 |
private: |
| 35 |
void initConsoleAppender(); |
| 36 |
void initRollingFileAppender(); |
| 37 |
void initJournalAppender(); |
| 38 |
QString joinPath(const QString &path, const QString &fileName); |
| 39 |
|
| 40 |
inline static DLogManager* instance(){ |
| 41 |
static DLogManager instance; |
| 42 |
return &instance; |
| 43 |
} |
| 44 |
explicit DLogManager(); |
| 45 |
~DLogManager(); |
| 46 |
|
| 47 |
QScopedPointer<DLogManagerPrivate> d_ptr; |
| 48 |
Q_DECLARE_PRIVATE(DLogManager) |
| 49 |
}; |
| 50 |
|
| 51 |
DCORE_END_NAMESPACE |
| 52 |
|
| 53 |
#endif // LOGMANAGER_H |