[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [akonadi-next/feature/akonadish_log_control] akonadish/syntax_modules: logging level setting
From:       Aaron Seigo <aseigo () kde ! org>
Date:       2016-01-10 10:26:03
Message-ID: E1aIDCF-0002IK-Dz () scm ! kde ! org
[Download RAW message or body]

Git commit b59a7fe545aa2732e98ecc373c4ab5ca741cd920 by Aaron Seigo.
Committed on 10/01/2016 at 10:20.
Pushed by aseigo into branch 'feature/akonadish_log_control'.

logging level setting

M  +26   -0    akonadish/syntax_modules/core_syntax.cpp

http://commits.kde.org/akonadi-next/b59a7fe545aa2732e98ecc373c4ab5ca741cd920

diff --git a/akonadish/syntax_modules/core_syntax.cpp \
b/akonadish/syntax_modules/core_syntax.cpp index b4812df..ccf96c1 100644
--- a/akonadish/syntax_modules/core_syntax.cpp
+++ b/akonadish/syntax_modules/core_syntax.cpp
@@ -24,6 +24,7 @@
 
 #include "state.h"
 #include "syntaxtree.h"
+#include "utils.h"
 
 namespace CoreSyntax
 {
@@ -145,6 +146,24 @@ bool printSyntaxTree(const QStringList &, State &state)
     return true;
 }
 
+bool setLoggingLevel(const QStringList &commands, State &state)
+{
+    if (commands.count() != 1) {
+        state.printError(QObject::tr("Wrong number of arguments; expected 1 got \
%1").arg(commands.count())); +        return false;
+    }
+
+    state.setLoggingLevel(commands.at(0));
+    return true;
+}
+
+bool printLoggingLevel(const QStringList &commands, State &state)
+{
+    const QString level = state.loggingLevel();
+    state.printLine(level);
+    return true;
+}
+
 Syntax::List syntax()
 {
     Syntax::List syntax;
@@ -158,15 +177,22 @@ Syntax::List syntax()
 
     Syntax set("set", QObject::tr("Sets settings for the session"));
     set.children << Syntax("debug", QObject::tr("Set the debug level from 0 to 6"), \
&CoreSyntax::setDebugLevel); +
     Syntax setTiming = Syntax("timing", QObject::tr("Whether or not to print the \
                time commands take to complete"));
     setTiming.children << Syntax("on", QString(), [](const QStringList &, State \
                &state) -> bool { state.setCommandTiming(true); return true; });
     setTiming.children << Syntax("off", QString(), [](const QStringList &, State \
&state) -> bool { state.setCommandTiming(false); return true; });  set.children << \
setTiming; +
+    Syntax logging("logging", QObject::tr("Set the logging level to one of Trace, \
Log, Warning or Error"), &CoreSyntax::setLoggingLevel); +    logging.completer = \
[](const QStringList &, const QString &fragment, State &state) -> QStringList { \
return Utils::filteredCompletions(QStringList() << "trace" << "log" << "warning" << \
"error", fragment, Qt::CaseInsensitive); }; +    set.children << logging;
+
     syntax << set;
 
     Syntax get("get", QObject::tr("Gets settings for the session"));
     get.children << Syntax("debug", QObject::tr("The current debug level from 0 to \
                6"), &CoreSyntax::printDebugLevel);
     get.children << Syntax("timing", QObject::tr("Whether or not to print the time \
commands take to complete"), &CoreSyntax::printCommandTiming); +    get.children << \
Syntax("logging", QObject::tr("The current logging level"), \
&CoreSyntax::printLoggingLevel);  syntax << get;
 
     return syntax;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic