summaryrefslogtreecommitdiffstats
path: root/common/log.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-03 09:01:05 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-03-03 09:01:05 +0100
commit4d9746c828558c9f872e0aed52442863affb25d5 (patch)
tree507d7c2ba67f47d3cbbcf01a722236ff1b48426b /common/log.cpp
parent9cea920b7dd51867a0be0fed2f461b6be73c103e (diff)
downloadsink-4d9746c828558c9f872e0aed52442863affb25d5.tar.gz
sink-4d9746c828558c9f872e0aed52442863affb25d5.zip
Fromatted the whole codebase with clang-format.
clang-format -i */**{.cpp,.h}
Diffstat (limited to 'common/log.cpp')
-rw-r--r--common/log.cpp75
1 files changed, 48 insertions, 27 deletions
diff --git a/common/log.cpp b/common/log.cpp
index 96c6f82..b0f6237 100644
--- a/common/log.cpp
+++ b/common/log.cpp
@@ -16,67 +16,88 @@ static QSharedPointer<QSettings> config()
16 return QSharedPointer<QSettings>::create(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/log.ini", QSettings::IniFormat); 16 return QSharedPointer<QSettings>::create(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/log.ini", QSettings::IniFormat);
17} 17}
18 18
19class DebugStream: public QIODevice 19class DebugStream : public QIODevice
20{ 20{
21public: 21public:
22 QString m_location; 22 QString m_location;
23 DebugStream() 23 DebugStream() : QIODevice()
24 : QIODevice()
25 { 24 {
26 open(WriteOnly); 25 open(WriteOnly);
27 } 26 }
28 virtual ~DebugStream(); 27 virtual ~DebugStream();
29 28
30 bool isSequential() const { return true; } 29 bool isSequential() const
31 qint64 readData(char *, qint64) { return 0; /* eof */ } 30 {
32 qint64 readLineData(char *, qint64) { return 0; /* eof */ } 31 return true;
32 }
33 qint64 readData(char *, qint64)
34 {
35 return 0; /* eof */
36 }
37 qint64 readLineData(char *, qint64)
38 {
39 return 0; /* eof */
40 }
33 qint64 writeData(const char *data, qint64 len) 41 qint64 writeData(const char *data, qint64 len)
34 { 42 {
35 std::cout << data << std::endl; 43 std::cout << data << std::endl;
36 return len; 44 return len;
37 } 45 }
46
38private: 47private:
39 Q_DISABLE_COPY(DebugStream) 48 Q_DISABLE_COPY(DebugStream)
40}; 49};
41 50
42//Virtual method anchor 51// Virtual method anchor
43DebugStream::~DebugStream() 52DebugStream::~DebugStream()
44{} 53{
54}
45 55
46class NullStream: public QIODevice 56class NullStream : public QIODevice
47{ 57{
48public: 58public:
49 NullStream() 59 NullStream() : QIODevice()
50 : QIODevice()
51 { 60 {
52 open(WriteOnly); 61 open(WriteOnly);
53 } 62 }
54 virtual ~NullStream(); 63 virtual ~NullStream();
55 64
56 bool isSequential() const { return true; } 65 bool isSequential() const
57 qint64 readData(char *, qint64) { return 0; /* eof */ } 66 {
58 qint64 readLineData(char *, qint64) { return 0; /* eof */ } 67 return true;
68 }
69 qint64 readData(char *, qint64)
70 {
71 return 0; /* eof */
72 }
73 qint64 readLineData(char *, qint64)
74 {
75 return 0; /* eof */
76 }
59 qint64 writeData(const char *data, qint64 len) 77 qint64 writeData(const char *data, qint64 len)
60 { 78 {
61 return len; 79 return len;
62 } 80 }
81
63private: 82private:
64 Q_DISABLE_COPY(NullStream) 83 Q_DISABLE_COPY(NullStream)
65}; 84};
66 85
67//Virtual method anchor 86// Virtual method anchor
68NullStream::~NullStream() 87NullStream::~NullStream()
69{} 88{
70 89}
71 /* 90
72 * ANSI color codes: 91/*
73 * 0: reset colors/style 92 * ANSI color codes:
74 * 1: bold 93 * 0: reset colors/style
75 * 4: underline 94 * 1: bold
76 * 30 - 37: black, red, green, yellow, blue, magenta, cyan, and white text 95 * 4: underline
77 * 40 - 47: black, red, green, yellow, blue, magenta, cyan, and white background 96 * 30 - 37: black, red, green, yellow, blue, magenta, cyan, and white text
78 */ 97 * 40 - 47: black, red, green, yellow, blue, magenta, cyan, and white background
79enum ANSI_Colors { 98 */
99enum ANSI_Colors
100{
80 DoNothing = -1, 101 DoNothing = -1,
81 Reset = 0, 102 Reset = 0,
82 Bold = 1, 103 Bold = 1,
@@ -211,7 +232,7 @@ static bool caseInsensitiveContains(const QByteArray &pattern, const QByteArrayL
211 return false; 232 return false;
212} 233}
213 234
214QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea) 235QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char *file, const char *function, const char *debugArea)
215{ 236{
216 static NullStream nullstream; 237 static NullStream nullstream;
217 if (debugLevel < debugOutputLevel()) { 238 if (debugLevel < debugOutputLevel()) {