summaryrefslogtreecommitdiffstats
path: root/sinksh/syntax_modules/sink_trace.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-08 11:01:48 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-08 11:01:48 +0200
commit9317fbffeab4a8c258acb1116eb12fbded7053d8 (patch)
treeb1f00b8ee96e222c16d25d02b49ade1ef3aee8ae /sinksh/syntax_modules/sink_trace.cpp
parent1b6439215fa0bb6ac1e191c2ffc992e815a53199 (diff)
downloadsink-9317fbffeab4a8c258acb1116eb12fbded7053d8.tar.gz
sink-9317fbffeab4a8c258acb1116eb12fbded7053d8.zip
Control debugoutput during tests with sinksh.
Diffstat (limited to 'sinksh/syntax_modules/sink_trace.cpp')
-rw-r--r--sinksh/syntax_modules/sink_trace.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/sinksh/syntax_modules/sink_trace.cpp b/sinksh/syntax_modules/sink_trace.cpp
index d480254..8bd52a0 100644
--- a/sinksh/syntax_modules/sink_trace.cpp
+++ b/sinksh/syntax_modules/sink_trace.cpp
@@ -31,6 +31,7 @@
31#include "sinksh_utils.h" 31#include "sinksh_utils.h"
32#include "state.h" 32#include "state.h"
33#include "syntaxtree.h" 33#include "syntaxtree.h"
34#include "iostream"
34 35
35namespace SinkTrace 36namespace SinkTrace
36{ 37{
@@ -38,22 +39,24 @@ namespace SinkTrace
38bool traceOff(const QStringList &args, State &state) 39bool traceOff(const QStringList &args, State &state)
39{ 40{
40 Sink::Log::setDebugOutputLevel(Sink::Log::Log); 41 Sink::Log::setDebugOutputLevel(Sink::Log::Log);
41 qDebug() << "Turned trace off: " << args; 42 std::cout << "Turned trace off." << std::endl;
42 return true; 43 return true;
43} 44}
44 45
45bool traceOn(const QStringList &args, State &state) 46bool traceOn(const QStringList &args, State &state)
46{ 47{
47 if (args.isEmpty()) {
48 state.printError(QObject::tr("Specifiy a debug area to trace: ") + Sink::Log::debugAreas().toList().join(", "));
49 return false;
50 }
51 Sink::Log::setDebugOutputLevel(Sink::Log::Trace); 48 Sink::Log::setDebugOutputLevel(Sink::Log::Trace);
52 QByteArrayList filter; 49 if (args.isEmpty() || (args.size() == 1 && args.first() == "*")) {
53 for (const auto &arg : args) { 50 Sink::Log::setDebugOutputFilter(Sink::Log::Area, QByteArrayList());
54 filter << arg.toLatin1(); 51 std::cout << "Set trace filter to: *" << std::endl;
52 } else {
53 QByteArrayList filter;
54 for (const auto &arg : args) {
55 filter << arg.toLatin1();
56 }
57 Sink::Log::setDebugOutputFilter(Sink::Log::Area, filter);
58 std::cout << "Set trace filter to: " << filter.join(", ").toStdString() << std::endl;
55 } 59 }
56 Sink::Log::setDebugOutputFilter(Sink::Log::Area, filter);
57 return true; 60 return true;
58} 61}
59 62