File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1717 */
1818
1919#include " consolecapture.h"
20+ #include " odsconsolecapture.h"
21+ #include " debugger.h"
22+
23+ #include < iostream>
2024
2125IConsoleCapture::IConsoleCapture (const QString &filename) :
2226 _filename(filename) {}
@@ -64,3 +68,28 @@ void CStreamCapture::close()
6468{
6569 closeFile ();
6670}
71+
72+ ConsoleOutputFiles captureConsoleOutput (const QString& path, const QString& prefix)
73+ {
74+ if (u::isDebuggerPresent ())
75+ return {};
76+
77+ auto filename = [&](const char * basename)
78+ {
79+ if (!prefix.isEmpty ())
80+ return QStringLiteral (" %1/%2_%3.txt" ).arg (path, prefix, basename);
81+
82+ return QStringLiteral (" %1/%2.txt" ).arg (path, basename);
83+ };
84+
85+ return
86+ {
87+ std::make_shared<IoStreamCapture>(filename (" cout" ), std::cout),
88+ std::make_shared<IoStreamCapture>(filename (" cerr" ), std::cerr),
89+ std::make_shared<CStreamCapture>(filename (" stdout" ), stdout),
90+ std::make_shared<CStreamCapture>(filename (" ctderr" ), stderr),
91+ #ifdef Q_OS_WIN
92+ std::make_shared<ODSCapture>(filename (" outputdebugstring" )),
93+ #endif
94+ };
95+ }
Original file line number Diff line number Diff line change @@ -61,4 +61,7 @@ class CStreamCapture : public IConsoleCapture
6161 void close () override ;
6262};
6363
64+ using ConsoleOutputFiles = std::vector<std::shared_ptr<IConsoleCapture>>;
65+ ConsoleOutputFiles captureConsoleOutput (const QString& path, const QString& prefix = {});
66+
6467#endif // CONSOLECAPTURE_H
You can’t perform that action at this time.
0 commit comments