Added option (#define CAPTURE_STDERR)
if set then the DebugTrace calls only for failing tests are shown
This commit is contained in:
@@ -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) \
|
||||
|
||||
28
JGE/include/OutputCapturer.h
Normal file
28
JGE/include/OutputCapturer.h
Normal 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
|
||||
Reference in New Issue
Block a user