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 | |
parent | ab750adc8c98bc33784498b4d06c36798f52ff4b (diff) | |
download | sink-646e552ba7410a925748ffe5e191ac577570f163.tar.gz sink-646e552ba7410a925748ffe5e191ac577570f163.zip |
Warning on command failure, null debugstream to ignore messages
-rw-r--r-- | common/clientapi.h | 13 | ||||
-rw-r--r-- | common/log.cpp | 26 |
2 files changed, 36 insertions, 3 deletions
diff --git a/common/clientapi.h b/common/clientapi.h index a01db23..4644ae1 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "resultprovider.h" | 35 | #include "resultprovider.h" |
36 | #include "domain/applicationdomaintype.h" | 36 | #include "domain/applicationdomaintype.h" |
37 | #include "resourceconfig.h" | 37 | #include "resourceconfig.h" |
38 | #include "log.h" | ||
38 | 39 | ||
39 | namespace async { | 40 | namespace async { |
40 | //This should abstract if we execute from eventloop or in thread. | 41 | //This should abstract if we execute from eventloop or in thread. |
@@ -277,7 +278,9 @@ public: | |||
277 | //Potentially move to separate thread as well | 278 | //Potentially move to separate thread as well |
278 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); | 279 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); |
279 | if (facade) { | 280 | if (facade) { |
280 | facade->create(domainObject).exec().waitForFinished(); | 281 | facade->create(domainObject).template then<void>([](){}, [](int errorCode, const QString &error) { |
282 | Warning() << "Failed to create"; | ||
283 | }).exec().waitForFinished(); | ||
281 | } | 284 | } |
282 | //TODO return job? | 285 | //TODO return job? |
283 | } | 286 | } |
@@ -292,7 +295,9 @@ public: | |||
292 | //Potentially move to separate thread as well | 295 | //Potentially move to separate thread as well |
293 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); | 296 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); |
294 | if (facade) { | 297 | if (facade) { |
295 | facade->modify(domainObject).exec().waitForFinished(); | 298 | facade->modify(domainObject).template then<void>([](){}, [](int errorCode, const QString &error) { |
299 | Warning() << "Failed to modify"; | ||
300 | }).exec().waitForFinished(); | ||
296 | } | 301 | } |
297 | //TODO return job? | 302 | //TODO return job? |
298 | } | 303 | } |
@@ -305,7 +310,9 @@ public: | |||
305 | //Potentially move to separate thread as well | 310 | //Potentially move to separate thread as well |
306 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); | 311 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); |
307 | if (facade) { | 312 | if (facade) { |
308 | facade->remove(domainObject).exec().waitForFinished(); | 313 | facade->remove(domainObject).template then<void>([](){}, [](int errorCode, const QString &error) { |
314 | Warning() << "Failed to remove"; | ||
315 | }).exec().waitForFinished(); | ||
309 | } | 316 | } |
310 | //TODO return job? | 317 | //TODO return job? |
311 | } | 318 | } |
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 | ||