TTKMusicPlayer
4.1.3.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
TTKCommon
ttklogger.h
Go to the documentation of this file.
1
#ifndef TTKLOGGER_H
2
#define TTKLOGGER_H
3
4
/***************************************************************************
5
* This file is part of the TTK Library Module project
6
* Copyright (C) 2015 - 2025 Greedysky Studio
7
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser General Public License as published by
10
* the Free Software Foundation; either version 3 of the License, or
11
* (at your option) any later version.
12
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Lesser General Public License for more details.
17
18
* You should have received a copy of the GNU Lesser General Public License along
19
* with this program; If not, see <http://www.gnu.org/licenses/>.
20
***************************************************************************/
21
22
#include <QDebug>
23
#include <QDateTime>
24
#include "
ttkglobal.h
"
25
26
#if QT_VERSION < QT_VERSION_CHECK(5,4,0)
27
# define __TTK_LOG_OUTPUT__ qDebug()
28
#else
29
# define __TTK_LOG_OUTPUT__ qDebug().noquote()
30
#endif
31
32
#define __TTK_DATE__ QDate::currentDate().toString(TTK_DATE_FORMAT)
33
#define __TTK_TIME__ QTime::currentTime().toString(TTK_TIMEZ_FORMAT)
34
35
// log stream base macro
36
#define __TTK_BASE_STREAM__(level, msg) __TTK_LOG_OUTPUT__ << QString("[%1 %2][%3][%4(%5)] ").arg(__TTK_DATE__, __TTK_TIME__, level, __FILE__, QString::number(__LINE__)) << msg
37
// log stream once base macro
38
#define __TTK_ONCE_STREAM__(level, msg) \
39
static bool __hit__ = false; \
40
if(!__hit__) \
41
{ \
42
__hit__ = true; \
43
__TTK_BASE_STREAM__(level, msg); \
44
}
45
// log stream count base macro
46
#define __TTK_COUNT_STREAM__(count, level, msg) \
47
static int __last__ = 1; \
48
if(count > 0 && ++__last__ > count) \
49
{ \
50
__last__ = 1; \
51
__TTK_BASE_STREAM__(level, msg); \
52
}
53
// log stream period base macro
54
#define __TTK_PERIOD_STREAM__(period, level, msg) \
55
static qint64 __last__ = 0; \
56
const qint64 __now__ = QDateTime::currentMSecsSinceEpoch(); \
57
if(__last__ + period * 1000 <= __now__ || __now__ < __last__) \
58
{ \
59
__last__ = __now__; \
60
__TTK_BASE_STREAM__(level, msg); \
61
}
62
63
64
#define TTK_LOG_STREAM(msg) __TTK_LOG_OUTPUT__ << msg
65
66
#define TTK_TRACE_STREAM(msg) { __TTK_BASE_STREAM__("T", msg); }
67
#define TTK_DEBUG_STREAM(msg) { __TTK_BASE_STREAM__("D", msg); }
68
#define TTK_INFO_STREAM(msg) { __TTK_BASE_STREAM__("I", msg); }
69
#define TTK_WARN_STREAM(msg) { __TTK_BASE_STREAM__("W", msg); }
70
#define TTK_ERROR_STREAM(msg) { __TTK_BASE_STREAM__("E", msg); }
71
#define TTK_FATAL_STREAM(msg) { __TTK_BASE_STREAM__("F", msg); }
72
73
#define TTK_TRACE_STREAM_ONCE(msg) { __TTK_ONCE_STREAM__("T", msg) }
74
#define TTK_DEBUG_STREAM_ONCE(msg) { __TTK_ONCE_STREAM__("D", msg) }
75
#define TTK_INFO_STREAM_ONCE(msg) { __TTK_ONCE_STREAM__("I", msg) }
76
#define TTK_WARN_STREAM_ONCE(msg) { __TTK_ONCE_STREAM__("W", msg) }
77
#define TTK_ERROR_STREAM_ONCE(msg) { __TTK_ONCE_STREAM__("E", msg) }
78
#define TTK_FATAL_STREAM_ONCE(msg) { __TTK_ONCE_STREAM__("F", msg) }
79
80
#define TTK_TRACE_STREAM_COUNT(count, msg) { __TTK_COUNT_STREAM__(count, "T", msg) }
81
#define TTK_DEBUG_STREAM_COUNT(count, msg) { __TTK_COUNT_STREAM__(count, "D", msg) }
82
#define TTK_INFO_STREAM_COUNT(count, msg) { __TTK_COUNT_STREAM__(count, "I", msg) }
83
#define TTK_WARN_STREAM_COUNT(count, msg) { __TTK_COUNT_STREAM__(count, "W", msg) }
84
#define TTK_ERROR_STREAM_COUNT(count, msg) { __TTK_COUNT_STREAM__(count, "E", msg) }
85
#define TTK_FATAL_STREAM_COUNT(count, msg) { __TTK_COUNT_STREAM__(count, "F", msg) }
86
87
#define TTK_TRACE_STREAM_PERIOD(period, msg) { __TTK_PERIOD_STREAM__(period, "T", msg) }
88
#define TTK_DEBUG_STREAM_PERIOD(period, msg) { __TTK_PERIOD_STREAM__(period, "D", msg) }
89
#define TTK_INFO_STREAM_PERIOD(period, msg) { __TTK_PERIOD_STREAM__(period, "I", msg) }
90
#define TTK_WARN_STREAM_PERIOD(period, msg) { __TTK_PERIOD_STREAM__(period, "W", msg) }
91
#define TTK_ERROR_STREAM_PERIOD(period, msg) { __TTK_PERIOD_STREAM__(period, "E", msg) }
92
#define TTK_FATAL_STREAM_PERIOD(period, msg) { __TTK_PERIOD_STREAM__(period, "F", msg) }
93
94
#endif // TTKLOGGER_H
ttkglobal.h
Generated on Tue Jan 21 2025 21:07:12 for TTKMusicPlayer by
1.8.8