File: LogManager.h

package info (click to toggle)
dtkcore 5.7.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,728 kB
  • sloc: cpp: 22,021; ansic: 183; python: 68; xml: 58; makefile: 27; sh: 15
file content (53 lines) | stat: -rw-r--r-- 1,314 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#ifndef LOGMANAGER_H
#define LOGMANAGER_H

#include <QScopedPointer>

#include "dtkcore_global.h"

DCORE_BEGIN_NAMESPACE

class DLogManagerPrivate;
class LIBDTKCORESHARED_EXPORT DLogManager
{
    Q_DISABLE_COPY(DLogManager)
public:
    static void registerConsoleAppender();
    static void registerFileAppender();
    static void registerJournalAppender();

    static QString getlogFilePath();

    /*!
     * \brief setlogFilePath will change log file path of registerFileAppender
     * \a logFilePath is the full path of file appender log
     */
    static void setlogFilePath(const QString &logFilePath);

    static void setLogFormat(const QString &format);

private:
    void initConsoleAppender();
    void initRollingFileAppender();
    void initJournalAppender();
    QString joinPath(const QString &path, const QString &fileName);

    inline static DLogManager* instance(){
        static DLogManager instance;
        return &instance;
    }
    explicit DLogManager();
    ~DLogManager();

    QScopedPointer<DLogManagerPrivate> d_ptr;
    Q_DECLARE_PRIVATE(DLogManager)
};

DCORE_END_NAMESPACE

#endif // LOGMANAGER_H