summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/TestOptions.h
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-07-24 19:39:27 +0000
committerAlan Conway <aconway@apache.org>2007-07-24 19:39:27 +0000
commitc2efe8deabde635f07e78d438fc529ca67d34133 (patch)
tree5a72156552781e1044dbecfb7ae41b71be51a6c7 /qpid/cpp/src/tests/TestOptions.h
parentf6ce4582d32b38dee7139dd286a7abcc4f8695cc (diff)
downloadqpid-python-c2efe8deabde635f07e78d438fc529ca67d34133.tar.gz
* Summary:
- Wiring (declare/delete/bind) is replicated via AIS. - TestOptions includes all logging options. - Logger automatically parses env vars so logging can be enabled for any program linked with libqpidcommon e.g. by setting QPID_TRACE=1. * src/qpid/cluster/SessionManager.cpp: Handle frames from cluster - Forward to BrokerAdapter for execution. - Suppress responses in proxy. * src/tests/TestOptions.h (Options): Logging options, --help option. * src/qpid/client/ClientConnection.cpp: Removed log initialization. Logs are initialized either in TestOptions or automatically from env vars, e.g. QPID_TRACE, * src/qpid/QpidError.h (class QpidError): Initialize Exception in constructor so messages can be logged. * src/qpid/framing/ChannelAdapter.h: Made send() virtual. * src/tests/Cluster_child.cpp: UUID corrected. * src/qpid/broker/Broker.cpp: Pass chains to updater by ref. * src/qpid/Options.cpp (parse): Fix log settings from environment. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@559171 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/TestOptions.h')
-rw-r--r--qpid/cpp/src/tests/TestOptions.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/qpid/cpp/src/tests/TestOptions.h b/qpid/cpp/src/tests/TestOptions.h
index ee3af0873a..5b3c0958f5 100644
--- a/qpid/cpp/src/tests/TestOptions.h
+++ b/qpid/cpp/src/tests/TestOptions.h
@@ -22,13 +22,18 @@
*/
#include "qpid/Options.h"
+#include "qpid/log/Options.h"
#include "qpid/Url.h"
+#include "qpid/log/Logger.h"
+
+#include <iostream>
+#include <exception>
namespace qpid {
struct TestOptions : public qpid::Options
{
- TestOptions() : Options("Test Options"), host("localhost"), port(TcpAddress::DEFAULT_PORT), clientid("cpp"), trace(false), help(false)
+ TestOptions() : Options("Test Options"), host("localhost"), port(TcpAddress::DEFAULT_PORT), clientid("cpp"), help(false)
{
addOptions()
("host,h", optValue(host, "HOST"), "Broker host to connect to")
@@ -39,10 +44,26 @@ struct TestOptions : public qpid::Options
("clientname,n", optValue(clientid, "ID"), "unique client identifier")
("username", optValue(username, "USER"), "user name for broker log in.")
("password", optValue(password, "USER"), "password for broker log in.")
- ("trace,t", optValue(trace), "Turn on debug tracing.")
("help", optValue(help), "print this usage statement");
+ add(log);
}
+ /** As well as parsing, print help & exit if required */
+ void parse(int argc, char** argv) {
+ try {
+ qpid::Options::parse(argc, argv);
+ } catch (const std::exception& e) {
+ std::cout << e.what() << std::endl << *this << std::endl;
+ exit(1);
+ }
+ if (help) {
+ std::cout << *this << std::endl;
+ exit(0);
+ }
+ trace = log.trace;
+ qpid::log::Logger::instance().configure(log, argv[0]);
+ }
+
std::string host;
uint16_t port;
std::string virtualhost;
@@ -51,6 +72,7 @@ struct TestOptions : public qpid::Options
std::string password;
bool trace;
bool help;
+ log::Options log;
};
}