Added option (#define CAPTURE_STDERR)

if set then the DebugTrace calls only for failing tests are shown
This commit is contained in:
Dmitry Panin
2013-11-19 02:41:30 +04:00
parent 6294bb1eed
commit 6c41e5c92c
7 changed files with 63 additions and 2 deletions

View File

@@ -4,6 +4,8 @@
// dirty, but I get OS header includes this way
#include "JGE.h"
#include "OutputCapturer.h"
#include <ostream>
#include <iostream>
#include <iomanip>
@@ -29,12 +31,23 @@ std::string ToHex(T* pointer)
#if defined (WIN32) || defined (LINUX)
#ifdef QT_CONFIG
#ifdef CAPTURE_STDERR
#define DebugTrace(inString) \
{ \
std::ostringstream stream; \
stream << inString; \
qDebug("%s", stream.str().c_str()); \
OutputCapturer::add(stream.str()); \
}
#else // CAPTURE_STDERR
#define DebugTrace(inString) \
{ \
std::ostringstream stream; \
stream << inString; \
qDebug("%s", stream.str().c_str()); \
}
#endif // CAPTURE_STDERR
#elif defined (ANDROID)
#include <android/log.h>
#define DebugTrace(inString) \

View File

@@ -0,0 +1,28 @@
#ifndef OUTPUTCAPTURER_H
#define OUTPUTCAPTURER_H
#if defined(QT_CONFIG)
#include <Qt>
#include <string>
#include <sstream>
class OutputCapturer
{
private:
static std::ostringstream stream;
public:
static void add(const std::string& s) {
stream << s << "\n";
}
static void debugAndClear() {
stream.flush();
qDebug("%s", stream.str().c_str());
stream.str("");
}
static void clear() {
stream.str("");
}
};
#endif
#endif // OUTPUTCAPTURER_H