diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-07 16:06:01 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-07 17:42:25 +0200 |
commit | 9bcb822963fc96c94dbe7dcc4134dcd2dac454ff (patch) | |
tree | 39a946ff8ae7119edb27342e96b65a9785282706 | |
parent | 9bf9c5c6b08fd086f40a39f033293ff02d9e7fd5 (diff) | |
download | sink-9bcb822963fc96c94dbe7dcc4134dcd2dac454ff.tar.gz sink-9bcb822963fc96c94dbe7dcc4134dcd2dac454ff.zip |
Prepared sinksh trace
-rw-r--r-- | common/log.cpp | 6 | ||||
-rw-r--r-- | common/log.h | 2 | ||||
-rw-r--r-- | common/test.cpp | 1 | ||||
-rw-r--r-- | sinksh/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sinksh/sinksh_utils.cpp | 14 | ||||
-rw-r--r-- | sinksh/sinksh_utils.h | 1 | ||||
-rw-r--r-- | sinksh/syntax_modules/sink_trace.cpp | 72 | ||||
-rw-r--r-- | synchronizer/main.cpp | 1 |
8 files changed, 93 insertions, 5 deletions
diff --git a/common/log.cpp b/common/log.cpp index b0f6237..83cdc8a 100644 --- a/common/log.cpp +++ b/common/log.cpp | |||
@@ -16,6 +16,12 @@ static QSharedPointer<QSettings> config() | |||
16 | return QSharedPointer<QSettings>::create(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/log.ini", QSettings::IniFormat); | 16 | return QSharedPointer<QSettings>::create(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/log.ini", QSettings::IniFormat); |
17 | } | 17 | } |
18 | 18 | ||
19 | static QByteArray sPrimaryComponent; | ||
20 | void Sink::Log::setPrimaryComponent(const QString &component) | ||
21 | { | ||
22 | sPrimaryComponent = component.toUtf8(); | ||
23 | } | ||
24 | |||
19 | class DebugStream : public QIODevice | 25 | class DebugStream : public QIODevice |
20 | { | 26 | { |
21 | public: | 27 | public: |
diff --git a/common/log.h b/common/log.h index 0e92ea9..36b8efe 100644 --- a/common/log.h +++ b/common/log.h | |||
@@ -14,6 +14,8 @@ enum DebugLevel | |||
14 | Error | 14 | Error |
15 | }; | 15 | }; |
16 | 16 | ||
17 | void SINK_EXPORT setPrimaryComponent(const QString &component); | ||
18 | |||
17 | QByteArray SINK_EXPORT debugLevelName(DebugLevel debugLevel); | 19 | QByteArray SINK_EXPORT debugLevelName(DebugLevel debugLevel); |
18 | DebugLevel SINK_EXPORT debugLevelFromName(const QByteArray &name); | 20 | DebugLevel SINK_EXPORT debugLevelFromName(const QByteArray &name); |
19 | 21 | ||
diff --git a/common/test.cpp b/common/test.cpp index 59ad9ec..c7d84cc 100644 --- a/common/test.cpp +++ b/common/test.cpp | |||
@@ -45,6 +45,7 @@ void Sink::Test::initTest() | |||
45 | QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)).removeRecursively(); | 45 | QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)).removeRecursively(); |
46 | // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation); | 46 | // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation); |
47 | QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively(); | 47 | QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively(); |
48 | Log::setPrimaryComponent("test"); | ||
48 | } | 49 | } |
49 | 50 | ||
50 | void Sink::Test::setTestModeEnabled(bool enabled) | 51 | void Sink::Test::setTestModeEnabled(bool enabled) |
diff --git a/sinksh/CMakeLists.txt b/sinksh/CMakeLists.txt index e7d3b6e..f0e2f6c 100644 --- a/sinksh/CMakeLists.txt +++ b/sinksh/CMakeLists.txt | |||
@@ -15,6 +15,7 @@ set(sink_cli_SRCS | |||
15 | syntax_modules/sink_stat.cpp | 15 | syntax_modules/sink_stat.cpp |
16 | syntax_modules/sink_sync.cpp | 16 | syntax_modules/sink_sync.cpp |
17 | syntax_modules/sink_show.cpp | 17 | syntax_modules/sink_show.cpp |
18 | syntax_modules/sink_trace.cpp | ||
18 | sinksh_utils.cpp | 19 | sinksh_utils.cpp |
19 | repl/repl.cpp | 20 | repl/repl.cpp |
20 | repl/replStates.cpp | 21 | repl/replStates.cpp |
diff --git a/sinksh/sinksh_utils.cpp b/sinksh/sinksh_utils.cpp index 091eb38..2a6f628 100644 --- a/sinksh/sinksh_utils.cpp +++ b/sinksh/sinksh_utils.cpp | |||
@@ -113,6 +113,14 @@ QStringList resourceIds(State &state) | |||
113 | return resources; | 113 | return resources; |
114 | } | 114 | } |
115 | 115 | ||
116 | QStringList debugareaCompleter(const QStringList &, const QString &fragment, State &state) | ||
117 | { | ||
118 | QStringList list; | ||
119 | list << "foo.bar" << "tar.war" << "bluub"; | ||
120 | // return Utils::filteredCompletions(debugAreas(state), fragment); | ||
121 | return Utils::filteredCompletions(list, fragment); | ||
122 | } | ||
123 | |||
116 | QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state) | 124 | QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state) |
117 | { | 125 | { |
118 | return Utils::filteredCompletions(resourceIds(state), fragment); | 126 | return Utils::filteredCompletions(resourceIds(state), fragment); |
@@ -120,11 +128,7 @@ QStringList resourceCompleter(const QStringList &, const QString &fragment, Stat | |||
120 | 128 | ||
121 | QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state) | 129 | QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state) |
122 | { | 130 | { |
123 | static QStringList types = QStringList() << "resource" | 131 | static QStringList types = s_types; |
124 | << "folder" | ||
125 | << "mail" | ||
126 | << "event" | ||
127 | << "account"; | ||
128 | if (commands.count() == 1) { | 132 | if (commands.count() == 1) { |
129 | return Utils::filteredCompletions(s_types, fragment); | 133 | return Utils::filteredCompletions(s_types, fragment); |
130 | } | 134 | } |
diff --git a/sinksh/sinksh_utils.h b/sinksh/sinksh_utils.h index b5b6f3c..0a47661 100644 --- a/sinksh/sinksh_utils.h +++ b/sinksh/sinksh_utils.h | |||
@@ -40,6 +40,7 @@ QStringList resourceIds(); | |||
40 | QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state); | 40 | QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state); |
41 | QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state); | 41 | QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state); |
42 | QStringList typeCompleter(const QStringList &commands, const QString &fragment, State &state); | 42 | QStringList typeCompleter(const QStringList &commands, const QString &fragment, State &state); |
43 | QStringList debugareaCompleter(const QStringList &, const QString &fragment, State &state); | ||
43 | QMap<QString, QString> keyValueMapFromArgs(const QStringList &args); | 44 | QMap<QString, QString> keyValueMapFromArgs(const QStringList &args); |
44 | 45 | ||
45 | /** | 46 | /** |
diff --git a/sinksh/syntax_modules/sink_trace.cpp b/sinksh/syntax_modules/sink_trace.cpp new file mode 100644 index 0000000..e7b92de --- /dev/null +++ b/sinksh/syntax_modules/sink_trace.cpp | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #include <QDebug> | ||
21 | #include <QObject> // tr() | ||
22 | #include <QTimer> | ||
23 | |||
24 | #include "common/resource.h" | ||
25 | #include "common/storage.h" | ||
26 | #include "common/resourceconfig.h" | ||
27 | #include "common/log.h" | ||
28 | #include "common/storage.h" | ||
29 | #include "common/definitions.h" | ||
30 | |||
31 | #include "sinksh_utils.h" | ||
32 | #include "state.h" | ||
33 | #include "syntaxtree.h" | ||
34 | |||
35 | namespace SinkTrace | ||
36 | { | ||
37 | |||
38 | bool trace(const QStringList &args, State &state) | ||
39 | { | ||
40 | // if (args.isEmpty()) { | ||
41 | // state.printError(QObject::tr("Specifiy a debug area to trace.")); | ||
42 | // return false; | ||
43 | // } | ||
44 | // | ||
45 | // | ||
46 | qDebug() << "Trace arguments: " << args; | ||
47 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); | ||
48 | // Sink::Log::setDebugOutputFilter(Sink::Log::FilterType::Area, "filter"); | ||
49 | |||
50 | return true; | ||
51 | } | ||
52 | |||
53 | bool traceOff(const QStringList &args, State &state) | ||
54 | { | ||
55 | Sink::Log::setDebugOutputLevel(Sink::Log::Log); | ||
56 | qDebug() << "Turned trace off: " << args; | ||
57 | return true; | ||
58 | } | ||
59 | |||
60 | Syntax::List syntax() | ||
61 | { | ||
62 | Syntax trace("trace", QObject::tr("Control trace debug output."), &SinkTrace::trace, Syntax::NotInteractive); | ||
63 | trace.completer = &SinkshUtils::debugareaCompleter; | ||
64 | |||
65 | trace.children << Syntax("off", QObject::tr("Turns off trace output."), &SinkTrace::traceOff, Syntax::NotInteractive); | ||
66 | |||
67 | return Syntax::List() << trace; | ||
68 | } | ||
69 | |||
70 | REGISTER_SYNTAX(SinkTrace) | ||
71 | |||
72 | } | ||
diff --git a/synchronizer/main.cpp b/synchronizer/main.cpp index 3168bfc..b3decf6 100644 --- a/synchronizer/main.cpp +++ b/synchronizer/main.cpp | |||
@@ -162,6 +162,7 @@ int main(int argc, char *argv[]) | |||
162 | const QByteArray instanceIdentifier = arguments.at(1); | 162 | const QByteArray instanceIdentifier = arguments.at(1); |
163 | const QByteArray resourceType = arguments.at(2); | 163 | const QByteArray resourceType = arguments.at(2); |
164 | app.setApplicationName(instanceIdentifier); | 164 | app.setApplicationName(instanceIdentifier); |
165 | Sink::Log::setPrimaryComponent(instanceIdentifier); | ||
165 | Log() << "Starting: " << instanceIdentifier; | 166 | Log() << "Starting: " << instanceIdentifier; |
166 | 167 | ||
167 | QLockFile lockfile(instanceIdentifier + ".lock"); | 168 | QLockFile lockfile(instanceIdentifier + ".lock"); |