diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-21 18:50:35 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-23 17:38:15 +0200 |
commit | 646e552ba7410a925748ffe5e191ac577570f163 (patch) | |
tree | 424b725e2304af3201050f7a5d31fb15eefbd217 /common/log.cpp | |
parent | ab750adc8c98bc33784498b4d06c36798f52ff4b (diff) | |
download | sink-646e552ba7410a925748ffe5e191ac577570f163.tar.gz sink-646e552ba7410a925748ffe5e191ac577570f163.zip |
Warning on command failure, null debugstream to ignore messages
Diffstat (limited to 'common/log.cpp')
-rw-r--r-- | common/log.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/common/log.cpp b/common/log.cpp index 14869bb..95a9c01 100644 --- a/common/log.cpp +++ b/common/log.cpp | |||
@@ -33,6 +33,27 @@ private: | |||
33 | Q_DISABLE_COPY(DebugStream) | 33 | Q_DISABLE_COPY(DebugStream) |
34 | }; | 34 | }; |
35 | 35 | ||
36 | class NullStream: public QIODevice | ||
37 | { | ||
38 | public: | ||
39 | NullStream() | ||
40 | : QIODevice() | ||
41 | { | ||
42 | open(WriteOnly); | ||
43 | } | ||
44 | virtual ~NullStream(){}; | ||
45 | |||
46 | bool isSequential() const { return true; } | ||
47 | qint64 readData(char *, qint64) { return 0; /* eof */ } | ||
48 | qint64 readLineData(char *, qint64) { return 0; /* eof */ } | ||
49 | qint64 writeData(const char *data, qint64 len) | ||
50 | { | ||
51 | return len; | ||
52 | } | ||
53 | private: | ||
54 | Q_DISABLE_COPY(NullStream) | ||
55 | }; | ||
56 | |||
36 | /* | 57 | /* |
37 | * ANSI color codes: | 58 | * ANSI color codes: |
38 | * 0: reset colors/style | 59 | * 0: reset colors/style |
@@ -75,6 +96,11 @@ static QString colorCommand(QList<int> colorCodes) | |||
75 | 96 | ||
76 | QDebug debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea) | 97 | QDebug debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea) |
77 | { | 98 | { |
99 | if (debugLevel <= DebugLevel::Trace) { | ||
100 | static NullStream stream; | ||
101 | return QDebug(&stream); | ||
102 | } | ||
103 | |||
78 | static DebugStream stream; | 104 | static DebugStream stream; |
79 | QDebug debug(&stream); | 105 | QDebug debug(&stream); |
80 | 106 | ||