diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-04 19:27:44 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-04 19:27:44 +0100 |
commit | b16f3a02c8a4904f75f5c10ccc7eedac845cd940 (patch) | |
tree | 25523184e29aa26ec072a1646811c0e2f18c3c46 /sinksh | |
parent | 8599c4d371139dc0d4444b128792cd499129d349 (diff) | |
download | sink-b16f3a02c8a4904f75f5c10ccc7eedac845cd940.tar.gz sink-b16f3a02c8a4904f75f5c10ccc7eedac845cd940.zip |
Added a way to set logging areas and filter.
Diffstat (limited to 'sinksh')
-rw-r--r-- | sinksh/syntax_modules/core_syntax.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sinksh/syntax_modules/core_syntax.cpp b/sinksh/syntax_modules/core_syntax.cpp index a05beb0..9325a7e 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 | ||
29 | namespace CoreSyntax | 30 | namespace CoreSyntax |
30 | { | 31 | { |
@@ -163,6 +164,38 @@ bool printLoggingLevel(const QStringList &commands, State &state) | |||
163 | return true; | 164 | return true; |
164 | } | 165 | } |
165 | 166 | ||
167 | bool 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::setAreas(areas); | ||
180 | return true; | ||
181 | } | ||
182 | |||
183 | bool 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::setFilter(filter); | ||
196 | return true; | ||
197 | } | ||
198 | |||
166 | Syntax::List syntax() | 199 | Syntax::List syntax() |
167 | { | 200 | { |
168 | Syntax::List syntax; | 201 | Syntax::List syntax; |
@@ -186,6 +219,12 @@ Syntax::List syntax() | |||
186 | logging.completer = [](const QStringList &, const QString &fragment, State &state) -> QStringList { return Utils::filteredCompletions(QStringList() << "trace" << "log" << "warning" << "error", fragment, Qt::CaseInsensitive); }; | 219 | logging.completer = [](const QStringList &, const QString &fragment, State &state) -> QStringList { return Utils::filteredCompletions(QStringList() << "trace" << "log" << "warning" << "error", fragment, Qt::CaseInsensitive); }; |
187 | set.children << logging; | 220 | set.children << logging; |
188 | 221 | ||
222 | Syntax loggingAreas("loggingAreas", QObject::tr("Set logging areas."), &CoreSyntax::setLoggingAreas); | ||
223 | set.children << loggingAreas; | ||
224 | |||
225 | Syntax loggingFilter("loggingFilter", QObject::tr("Set logging filter."), &CoreSyntax::setLoggingFilter); | ||
226 | set.children << loggingFilter; | ||
227 | |||
189 | syntax << set; | 228 | syntax << set; |
190 | 229 | ||
191 | Syntax get("get", QObject::tr("Gets settings for the session")); | 230 | Syntax get("get", QObject::tr("Gets settings for the session")); |