summaryrefslogtreecommitdiffstats
path: root/sinksh/syntax_modules
diff options
context:
space:
mode:
Diffstat (limited to 'sinksh/syntax_modules')
-rw-r--r--sinksh/syntax_modules/core_syntax.cpp55
-rw-r--r--sinksh/syntax_modules/sink_clear.cpp2
2 files changed, 55 insertions, 2 deletions
diff --git a/sinksh/syntax_modules/core_syntax.cpp b/sinksh/syntax_modules/core_syntax.cpp
index f5b6274..e90d894 100644
--- a/sinksh/syntax_modules/core_syntax.cpp
+++ b/sinksh/syntax_modules/core_syntax.cpp
@@ -25,6 +25,7 @@
25#include "state.h" 25#include "state.h"
26#include "syntaxtree.h" 26#include "syntaxtree.h"
27#include "utils.h" 27#include "utils.h"
28#include "common/log.h"
28 29
29namespace CoreSyntax 30namespace CoreSyntax
30{ 31{
@@ -32,7 +33,6 @@ namespace CoreSyntax
32bool exit(const QStringList &, State &) 33bool exit(const QStringList &, State &)
33{ 34{
34 ::exit(0); 35 ::exit(0);
35 return true;
36} 36}
37 37
38bool showHelp(const QStringList &commands, State &state) 38bool showHelp(const QStringList &commands, State &state)
@@ -164,6 +164,49 @@ bool printLoggingLevel(const QStringList &commands, State &state)
164 return true; 164 return true;
165} 165}
166 166
167bool setLoggingAreas(const QStringList &commands, State &state)
168{
169 if (commands.isEmpty()) {
170 state.printError(QObject::tr("Wrong number of arguments; expected logging areas."));
171 return false;
172 }
173
174 QByteArrayList areas;
175 for (const auto &c : commands) {
176 areas << c.toLatin1();
177 }
178
179 Sink::Log::setDebugOutputFilter(Sink::Log::Area, areas);
180 return true;
181}
182
183bool setLoggingFilter(const QStringList &commands, State &state)
184{
185 if (commands.isEmpty()) {
186 state.printError(QObject::tr("Wrong number of arguments; expected resource identifier or application names."));
187 return false;
188 }
189
190 QByteArrayList filter;
191 for (const auto &c : commands) {
192 filter << c.toLatin1();
193 }
194
195 Sink::Log::setDebugOutputFilter(Sink::Log::ApplicationName, filter);
196 return true;
197}
198
199bool setLoggingFields(const QStringList &commands, State &state)
200{
201 QByteArrayList output;
202 for (const auto &c : commands) {
203 output << c.toLatin1();
204 }
205
206 Sink::Log::setDebugOutputFields(output);
207 return true;
208}
209
167Syntax::List syntax() 210Syntax::List syntax()
168{ 211{
169 Syntax::List syntax; 212 Syntax::List syntax;
@@ -187,6 +230,16 @@ Syntax::List syntax()
187 logging.completer = [](const QStringList &, const QString &fragment, State &state) -> QStringList { return Utils::filteredCompletions(QStringList() << "trace" << "log" << "warning" << "error", fragment, Qt::CaseInsensitive); }; 230 logging.completer = [](const QStringList &, const QString &fragment, State &state) -> QStringList { return Utils::filteredCompletions(QStringList() << "trace" << "log" << "warning" << "error", fragment, Qt::CaseInsensitive); };
188 set.children << logging; 231 set.children << logging;
189 232
233 Syntax loggingAreas("loggingAreas", QObject::tr("Set logging areas."), &CoreSyntax::setLoggingAreas);
234 set.children << loggingAreas;
235
236 Syntax loggingFilter("loggingFilter", QObject::tr("Set logging filter."), &CoreSyntax::setLoggingFilter);
237 set.children << loggingFilter;
238
239 Syntax loggingFields("loggingFields", QObject::tr("Set logging fields."), &CoreSyntax::setLoggingFields);
240 loggingFields.completer = [](const QStringList &, const QString &fragment, State &state) -> QStringList { return Utils::filteredCompletions(QStringList() << "name" << "function" << "location" << "", fragment, Qt::CaseInsensitive); };
241 set.children << loggingFields;
242
190 syntax << set; 243 syntax << set;
191 244
192 Syntax get("get", QObject::tr("Gets settings for the session")); 245 Syntax get("get", QObject::tr("Gets settings for the session"));
diff --git a/sinksh/syntax_modules/sink_clear.cpp b/sinksh/syntax_modules/sink_clear.cpp
index d02c638..72d9a14 100644
--- a/sinksh/syntax_modules/sink_clear.cpp
+++ b/sinksh/syntax_modules/sink_clear.cpp
@@ -41,7 +41,7 @@ bool clear(const QStringList &args, State &state)
41{ 41{
42 for (const auto &resource : args) { 42 for (const auto &resource : args) {
43 state.print(QObject::tr("Removing local cache for '%1' ...").arg(resource)); 43 state.print(QObject::tr("Removing local cache for '%1' ...").arg(resource));
44 Sink::Store::removeFromDisk(resource.toLatin1()); 44 Sink::Store::removeDataFromDisk(resource.toLatin1()).exec().waitForFinished();
45 state.printLine(QObject::tr("done")); 45 state.printLine(QObject::tr("done"));
46 } 46 }
47 47