From 9bcb822963fc96c94dbe7dcc4134dcd2dac454ff Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 7 Jul 2016 16:06:01 +0200 Subject: Prepared sinksh trace --- sinksh/CMakeLists.txt | 1 + sinksh/sinksh_utils.cpp | 14 ++++--- sinksh/sinksh_utils.h | 1 + sinksh/syntax_modules/sink_trace.cpp | 72 ++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 sinksh/syntax_modules/sink_trace.cpp (limited to 'sinksh') 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 syntax_modules/sink_stat.cpp syntax_modules/sink_sync.cpp syntax_modules/sink_show.cpp + syntax_modules/sink_trace.cpp sinksh_utils.cpp repl/repl.cpp 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) return resources; } +QStringList debugareaCompleter(const QStringList &, const QString &fragment, State &state) +{ + QStringList list; + list << "foo.bar" << "tar.war" << "bluub"; + // return Utils::filteredCompletions(debugAreas(state), fragment); + return Utils::filteredCompletions(list, fragment); +} + QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state) { return Utils::filteredCompletions(resourceIds(state), fragment); @@ -120,11 +128,7 @@ QStringList resourceCompleter(const QStringList &, const QString &fragment, Stat QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state) { - static QStringList types = QStringList() << "resource" - << "folder" - << "mail" - << "event" - << "account"; + static QStringList types = s_types; if (commands.count() == 1) { return Utils::filteredCompletions(s_types, fragment); } 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(); QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state); QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state); QStringList typeCompleter(const QStringList &commands, const QString &fragment, State &state); +QStringList debugareaCompleter(const QStringList &, const QString &fragment, State &state); QMap keyValueMapFromArgs(const QStringList &args); /** 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 @@ +/* + * Copyright (C) 2016 Christian Mollekopf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include // tr() +#include + +#include "common/resource.h" +#include "common/storage.h" +#include "common/resourceconfig.h" +#include "common/log.h" +#include "common/storage.h" +#include "common/definitions.h" + +#include "sinksh_utils.h" +#include "state.h" +#include "syntaxtree.h" + +namespace SinkTrace +{ + +bool trace(const QStringList &args, State &state) +{ + // if (args.isEmpty()) { + // state.printError(QObject::tr("Specifiy a debug area to trace.")); + // return false; + // } + // + // + qDebug() << "Trace arguments: " << args; + Sink::Log::setDebugOutputLevel(Sink::Log::Trace); + // Sink::Log::setDebugOutputFilter(Sink::Log::FilterType::Area, "filter"); + + return true; +} + +bool traceOff(const QStringList &args, State &state) +{ + Sink::Log::setDebugOutputLevel(Sink::Log::Log); + qDebug() << "Turned trace off: " << args; + return true; +} + +Syntax::List syntax() +{ + Syntax trace("trace", QObject::tr("Control trace debug output."), &SinkTrace::trace, Syntax::NotInteractive); + trace.completer = &SinkshUtils::debugareaCompleter; + + trace.children << Syntax("off", QObject::tr("Turns off trace output."), &SinkTrace::traceOff, Syntax::NotInteractive); + + return Syntax::List() << trace; +} + +REGISTER_SYNTAX(SinkTrace) + +} -- cgit v1.2.3