diff options
-rw-r--r-- | common/log.cpp | 18 | ||||
-rw-r--r-- | common/log.h | 21 | ||||
-rw-r--r-- | sinksh/syntax_modules/core_syntax.cpp | 14 |
3 files changed, 31 insertions, 22 deletions
diff --git a/common/log.cpp b/common/log.cpp index ee28a3b..d2e5f47 100644 --- a/common/log.cpp +++ b/common/log.cpp | |||
@@ -142,17 +142,19 @@ Sink::Log::DebugLevel Sink::Log::debugOutputLevel() | |||
142 | return debugLevelFromName(qgetenv("SINKDEBUGLEVEL")); | 142 | return debugLevelFromName(qgetenv("SINKDEBUGLEVEL")); |
143 | } | 143 | } |
144 | 144 | ||
145 | void Sink::Log::setFilter(const QByteArrayList &filter) | 145 | void Sink::Log::setDebugOutputFilter(FilterType type, const QByteArrayList &filter) |
146 | { | 146 | { |
147 | qputenv("SINKDEBUGFILTER", filter.join(',')); | 147 | switch (type) { |
148 | } | 148 | case ApplicationName: |
149 | 149 | qputenv("SINKDEBUGFILTER", filter.join(',')); | |
150 | void Sink::Log::setAreas(const QByteArrayList &filter) | 150 | break; |
151 | { | 151 | case Area: |
152 | qputenv("SINKDEBUGAREAS", filter.join(',')); | 152 | qputenv("SINKDEBUGAREAS", filter.join(',')); |
153 | break; | ||
154 | } | ||
153 | } | 155 | } |
154 | 156 | ||
155 | void Sink::Log::setDebugOutput(const QByteArrayList &output) | 157 | void Sink::Log::setDebugOutputFields(const QByteArrayList &output) |
156 | { | 158 | { |
157 | qputenv("SINKDEBUGOUTPUT", output.join(',')); | 159 | qputenv("SINKDEBUGOUTPUT", output.join(',')); |
158 | } | 160 | } |
diff --git a/common/log.h b/common/log.h index 8a6c295..92d6cdd 100644 --- a/common/log.h +++ b/common/log.h | |||
@@ -24,25 +24,32 @@ DebugLevel SINKCOMMON_EXPORT debugLevelFromName(const QByteArray &name); | |||
24 | void SINKCOMMON_EXPORT setDebugOutputLevel(DebugLevel); | 24 | void SINKCOMMON_EXPORT setDebugOutputLevel(DebugLevel); |
25 | DebugLevel SINKCOMMON_EXPORT debugOutputLevel(); | 25 | DebugLevel SINKCOMMON_EXPORT debugOutputLevel(); |
26 | 26 | ||
27 | /// Set debug areas that should be logged | 27 | enum FilterType { |
28 | void SINKCOMMON_EXPORT setAreas(const QByteArrayList &areas); | 28 | Area, |
29 | ApplicationName | ||
30 | }; | ||
29 | 31 | ||
30 | /** | 32 | /** |
31 | * Set an application name filter. | 33 | * Sets a debug output filter. |
34 | * | ||
35 | * Everything that is not matching the filter is ignored. | ||
36 | * An empty filter matches everything. | ||
32 | * | 37 | * |
33 | * Note: In case of resources the identifier is the application name. | 38 | * Note: In case of resources the application name is the identifier. |
34 | */ | 39 | */ |
35 | void SINKCOMMON_EXPORT setFilter(const QByteArrayList &filter); | 40 | void SINKCOMMON_EXPORT setDebugOutputFilter(FilterType, const QByteArrayList &filter); |
36 | 41 | ||
37 | /** | 42 | /** |
38 | * Set an application debug output. | 43 | * Set the debug output fields. |
39 | * | 44 | * |
40 | * Currently supported are: | 45 | * Currently supported are: |
41 | * * Name: Application name used for filter. | 46 | * * Name: Application name used for filter. |
42 | * * Function: The function name: | 47 | * * Function: The function name: |
43 | * * Location: The source code location. | 48 | * * Location: The source code location. |
49 | * | ||
50 | * These are additional items to the default ones (level, area, message). | ||
44 | */ | 51 | */ |
45 | void SINKCOMMON_EXPORT setDebugOutput(const QByteArrayList &filter); | 52 | void SINKCOMMON_EXPORT setDebugOutputFields(const QByteArrayList &filter); |
46 | 53 | ||
47 | QDebug SINKCOMMON_EXPORT debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea = 0); | 54 | QDebug SINKCOMMON_EXPORT debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea = 0); |
48 | 55 | ||
diff --git a/sinksh/syntax_modules/core_syntax.cpp b/sinksh/syntax_modules/core_syntax.cpp index cb036b4..e90d894 100644 --- a/sinksh/syntax_modules/core_syntax.cpp +++ b/sinksh/syntax_modules/core_syntax.cpp | |||
@@ -176,7 +176,7 @@ bool setLoggingAreas(const QStringList &commands, State &state) | |||
176 | areas << c.toLatin1(); | 176 | areas << c.toLatin1(); |
177 | } | 177 | } |
178 | 178 | ||
179 | Sink::Log::setAreas(areas); | 179 | Sink::Log::setDebugOutputFilter(Sink::Log::Area, areas); |
180 | return true; | 180 | return true; |
181 | } | 181 | } |
182 | 182 | ||
@@ -192,18 +192,18 @@ bool setLoggingFilter(const QStringList &commands, State &state) | |||
192 | filter << c.toLatin1(); | 192 | filter << c.toLatin1(); |
193 | } | 193 | } |
194 | 194 | ||
195 | Sink::Log::setFilter(filter); | 195 | Sink::Log::setDebugOutputFilter(Sink::Log::ApplicationName, filter); |
196 | return true; | 196 | return true; |
197 | } | 197 | } |
198 | 198 | ||
199 | bool setLoggingOutput(const QStringList &commands, State &state) | 199 | bool setLoggingFields(const QStringList &commands, State &state) |
200 | { | 200 | { |
201 | QByteArrayList output; | 201 | QByteArrayList output; |
202 | for (const auto &c : commands) { | 202 | for (const auto &c : commands) { |
203 | output << c.toLatin1(); | 203 | output << c.toLatin1(); |
204 | } | 204 | } |
205 | 205 | ||
206 | Sink::Log::setDebugOutput(output); | 206 | Sink::Log::setDebugOutputFields(output); |
207 | return true; | 207 | return true; |
208 | } | 208 | } |
209 | 209 | ||
@@ -236,9 +236,9 @@ Syntax::List syntax() | |||
236 | Syntax loggingFilter("loggingFilter", QObject::tr("Set logging filter."), &CoreSyntax::setLoggingFilter); | 236 | Syntax loggingFilter("loggingFilter", QObject::tr("Set logging filter."), &CoreSyntax::setLoggingFilter); |
237 | set.children << loggingFilter; | 237 | set.children << loggingFilter; |
238 | 238 | ||
239 | Syntax loggingOutput("loggingOutput", QObject::tr("Set logging output."), &CoreSyntax::setLoggingFilter); | 239 | Syntax loggingFields("loggingFields", QObject::tr("Set logging fields."), &CoreSyntax::setLoggingFields); |
240 | loggingOutput.completer = [](const QStringList &, const QString &fragment, State &state) -> QStringList { return Utils::filteredCompletions(QStringList() << "name" << "function" << "location" << "", fragment, Qt::CaseInsensitive); }; | 240 | loggingFields.completer = [](const QStringList &, const QString &fragment, State &state) -> QStringList { return Utils::filteredCompletions(QStringList() << "name" << "function" << "location" << "", fragment, Qt::CaseInsensitive); }; |
241 | set.children << loggingOutput; | 241 | set.children << loggingFields; |
242 | 242 | ||
243 | syntax << set; | 243 | syntax << set; |
244 | 244 | ||