summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2015-04-27 16:52:27 +0000
committerAlan Conway <aconway@apache.org>2015-04-27 16:52:27 +0000
commitdb7b30e0f7e7e080071df08c6589036820bdb443 (patch)
treea6c114bf7a99e617a61b9d429eab0c6ef9af332d
parentada6ab9d5319de3545132aac23b880c7458e0c64 (diff)
downloadqpid-python-db7b30e0f7e7e080071df08c6589036820bdb443.tar.gz
NO-JIRA: Add log command to qpid-config to set log levels.
Get current level: qpid-config log Set new level: qpid-config log <newlevel> Fixed bugs in getLogLevel and in handling invalid log levels. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1676333 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/qpid/log/Logger.cpp10
-rwxr-xr-xqpid/tools/src/py/qpid-config9
-rw-r--r--qpid/tools/src/py/qpidtoollibs/broker.py4
3 files changed, 17 insertions, 6 deletions
diff --git a/qpid/cpp/src/qpid/log/Logger.cpp b/qpid/cpp/src/qpid/log/Logger.cpp
index 7b1e22f80c..fc254f2857 100644
--- a/qpid/cpp/src/qpid/log/Logger.cpp
+++ b/qpid/cpp/src/qpid/log/Logger.cpp
@@ -160,21 +160,23 @@ void Logger::add(Statement& s) {
}
void Logger::configure(const Options& opts) {
- options = opts;
clear();
Options o(opts);
if (o.trace)
o.selectors.push_back("trace+");
format(o);
select(Selector(o));
+ options = opts;
setPrefix(opts.prefix);
options.sinkOptions->setup(this);
}
void Logger::reconfigure(const std::vector<std::string>& selectors) {
- options.selectors = selectors;
- options.deselectors.clear();
- select(Selector(options));
+ Options o(options);
+ o.selectors = selectors;
+ o.deselectors.clear();
+ select(Selector(o));
+ options = o; // Don't update options till selectors has been validated.
}
void Logger::setPrefix(const std::string& p) { prefix = p; }
diff --git a/qpid/tools/src/py/qpid-config b/qpid/tools/src/py/qpid-config
index aaae4d7860..130f90a291 100755
--- a/qpid/tools/src/py/qpid-config
+++ b/qpid/tools/src/py/qpid-config
@@ -48,6 +48,7 @@ Usage: qpid-config [OPTIONS]
qpid-config [OPTIONS] add <type> <name> [--argument <property-name>=<property-value>]
qpid-config [OPTIONS] del <type> <name>
qpid-config [OPTIONS] list <type> [--show-property <property-name>]
+ qpid-config [OPTIONS] log [<logstring>]
qpid-config [OPTIONS] shutdown"""
description = """
@@ -78,6 +79,10 @@ Replication levels:
none - no replication
configuration - replicate queue and exchange existence and bindings, but not messages.
all - replicate configuration and messages
+
+Log <logstring> value:
+
+ Comma separated <module>:<level> pairs, e.g. 'info+,debug+:Broker,trace+:Queue'
"""
REPLICATE_LEVELS= ["none", "configuration", "all"]
@@ -824,6 +829,10 @@ def main(argv=None):
headers = [Header(a) for a in desired]
rows = [tuple([_clean_ref(o.get(a, "n/a")) for a in desired]) for o in objects]
display.formattedTable("Objects of type '%s'" % modifier, headers, rows)
+ elif cmd == "log" and len (args) == 1:
+ print "Log level:", bm.broker.getLogLevel()["level"]
+ elif cmd == "log" and len (args) == 2:
+ bm.broker.setLogLevel(args[1])
elif cmd == "shutdown":
try:
bm.broker._method("shutdown", {})
diff --git a/qpid/tools/src/py/qpidtoollibs/broker.py b/qpid/tools/src/py/qpidtoollibs/broker.py
index c584ea1681..fca6680067 100644
--- a/qpid/tools/src/py/qpidtoollibs/broker.py
+++ b/qpid/tools/src/py/qpidtoollibs/broker.py
@@ -47,7 +47,7 @@ class BrokerAgent(object):
"""
self.sess.close()
- def _method(self, method, arguments, addr="org.apache.qpid.broker:broker:amqp-broker", timeout=10):
+ def _method(self, method, arguments=None, addr="org.apache.qpid.broker:broker:amqp-broker", timeout=10):
props = {'method' : 'request',
'qmf.opcode' : '_method_request',
'x-amqp-0-10.app-id' : 'qmf2'}
@@ -56,7 +56,7 @@ class BrokerAgent(object):
content = {'_object_id' : {'_object_name' : addr},
'_method_name' : method,
- '_arguments' : arguments}
+ '_arguments' : arguments or {}}
message = self.message_class(
content, reply_to=self.reply_to, correlation_id=correlator,