diff options
| author | Alan Conway <aconway@apache.org> | 2007-05-30 16:13:58 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-05-30 16:13:58 +0000 |
| commit | 1d63a898503d20e3221be43fc222f0091971a0ce (patch) | |
| tree | 78d8673b9ed8820e431b6a6f353ba0143adeb800 /cpp/src/qpid/client | |
| parent | f2b034ea3f4fa70e512fafdf18fd42c370194329 (diff) | |
| download | qpid-python-1d63a898503d20e3221be43fc222f0091971a0ce.tar.gz | |
Logging infrastructure: See qpidd --long-help for details.
* src/qpid/log/*: Logging infrastructure, QPID_LOG macro.
* src/*: changed output to cout/cerr to logging.
* src/qpidd.cpp: logging options.
* src/tests/Makefile.am: fixed issues with valgrind
* src/tests/kill|start_broker: use broker daemon options.
* src/tests/run_test: run tests in valgrind. Disabled till leaks in
client_test are fixed.
* src/test/unit/logging.cpp: Logging unit test using boost test framework.
Eventually we should move all unit tests to boost & drop CppUnit.
* src/test/unit/test_tools.h: useful extensions to boost framework:
Regular expression check, ostream << for vectors.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@542855 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client')
| -rw-r--r-- | cpp/src/qpid/client/BasicMessageChannel.cpp | 6 | ||||
| -rw-r--r-- | cpp/src/qpid/client/ClientChannel.cpp | 9 | ||||
| -rw-r--r-- | cpp/src/qpid/client/ClientConnection.cpp | 15 | ||||
| -rw-r--r-- | cpp/src/qpid/client/Connector.cpp | 7 | ||||
| -rw-r--r-- | cpp/src/qpid/client/MessageMessageChannel.cpp | 6 |
5 files changed, 22 insertions, 21 deletions
diff --git a/cpp/src/qpid/client/BasicMessageChannel.cpp b/cpp/src/qpid/client/BasicMessageChannel.cpp index 96aaad05dc..91849c735e 100644 --- a/cpp/src/qpid/client/BasicMessageChannel.cpp +++ b/cpp/src/qpid/client/BasicMessageChannel.cpp @@ -15,6 +15,7 @@ * limitations under the License. * */ +#include "qpid/log/Statement.h" #include "BasicMessageChannel.h" #include "qpid/framing/AMQMethodBody.h" #include "ClientChannel.h" @@ -320,12 +321,11 @@ void BasicMessageChannel::run() { } } catch (const ShutdownException&) { - /* Orderly shutdown */ + // Orderly shutdown. } catch (const Exception& e) { // FIXME aconway 2007-02-20: Report exception to user. - cout << "client::BasicMessageChannel::run() terminated by: " - << e.toString() << endl; + QPID_LOG(error, e.what()); } } } diff --git a/cpp/src/qpid/client/ClientChannel.cpp b/cpp/src/qpid/client/ClientChannel.cpp index 05f01227f6..0cb0931155 100644 --- a/cpp/src/qpid/client/ClientChannel.cpp +++ b/cpp/src/qpid/client/ClientChannel.cpp @@ -18,6 +18,7 @@ * under the License. * */ +#include "qpid/log/Statement.h" #include <iostream> #include "ClientChannel.h" #include "qpid/sys/Monitor.h" @@ -112,8 +113,7 @@ void Channel::protocolInit( //ignore for now ConnectionRedirectBody::shared_ptr redirect( shared_polymorphic_downcast<ConnectionRedirectBody>(openResponse)); - cout << "Received redirection to " << redirect->getHost() - << endl; + QPID_LOG(error, "Ignoring redirect to " << redirect->getHost()); } else { THROW_QPID_ERROR(PROTOCOL_ERROR, "Bad response to Connection.open"); } @@ -189,9 +189,8 @@ void Channel::rollback(){ void Channel::handleMethodInContext( AMQMethodBody::shared_ptr method, const MethodContext&) { - // TODO aconway 2007-03-23: Special case for consume OK as it - // is both an expected response and needs handling in this thread. - // Need to review & reationalize the client-side processing model. + // Special case for consume OK as it is both an expected response + // and needs handling in this thread. if (method->isA<BasicConsumeOkBody>()) { messaging->handle(method); responses.signalResponse(method); diff --git a/cpp/src/qpid/client/ClientConnection.cpp b/cpp/src/qpid/client/ClientConnection.cpp index 177c9c4b73..d6d03680c1 100644 --- a/cpp/src/qpid/client/ClientConnection.cpp +++ b/cpp/src/qpid/client/ClientConnection.cpp @@ -25,6 +25,7 @@ #include "Connection.h" #include "ClientChannel.h" #include "ClientMessage.h" +#include "qpid/log/Statement.h" #include "qpid/QpidError.h" #include <iostream> #include <sstream> @@ -78,7 +79,7 @@ void Connection::shutdown() { //this indicates that the socket to the server has closed we do //not want to send a close request (or any other requests) if(markClosed()) { - std::cout << "Connection to peer closed!" << std::endl; + QPID_LOG(info, "Connection to peer closed!"); closeChannels(); } } @@ -88,11 +89,13 @@ void Connection::close( ) { if(markClosed()) { - // TODO aconway 2007-01-29: Exception handling - could end up - // partly closed with threads left unjoined. - channel0.sendAndReceive<ConnectionCloseOkBody>( - make_shared_ptr(new ConnectionCloseBody( - getVersion(), code, msg, classId, methodId))); + try { + channel0.sendAndReceive<ConnectionCloseOkBody>( + make_shared_ptr(new ConnectionCloseBody( + getVersion(), code, msg, classId, methodId))); + } catch (const std::exception& e) { + QPID_LOG(error, "Exception closing channel: " << e.what()); + } closeChannels(); connector->close(); } diff --git a/cpp/src/qpid/client/Connector.cpp b/cpp/src/qpid/client/Connector.cpp index 3447467fda..18cb0e064b 100644 --- a/cpp/src/qpid/client/Connector.cpp +++ b/cpp/src/qpid/client/Connector.cpp @@ -19,6 +19,7 @@ * */ #include <iostream> +#include "qpid/log/Statement.h" #include "qpid/QpidError.h" #include "qpid/sys/Time.h" #include "Connector.h" @@ -82,7 +83,7 @@ void Connector::send(AMQFrame* f){ std::auto_ptr<AMQFrame> frame(f); AMQBody::shared_ptr body = frame->getBody(); writeBlock(frame.get()); - if(debug) std::cout << "SENT: " << *frame << std::endl; + QPID_LOG(trace, "SENT: " << *frame); } void Connector::writeBlock(AMQDataBlock* data){ @@ -182,7 +183,7 @@ void Connector::run(){ AMQFrame frame(version); while(frame.decode(inbuf)){ - if(debug) std::cout << "RECV: " << frame << std::endl; + QPID_LOG(trace, "RECV: " << frame); input->received(&frame); } //need to compact buffer to preserve any 'extra' data @@ -190,7 +191,7 @@ void Connector::run(){ } } } catch (const std::exception& e) { - std::cout << e.what() << std::endl; + QPID_LOG(error, e.what()); handleClosed(); } } diff --git a/cpp/src/qpid/client/MessageMessageChannel.cpp b/cpp/src/qpid/client/MessageMessageChannel.cpp index 6ba5e00153..c73f501ec5 100644 --- a/cpp/src/qpid/client/MessageMessageChannel.cpp +++ b/cpp/src/qpid/client/MessageMessageChannel.cpp @@ -381,7 +381,7 @@ void MessageMessageChannel::run() { // } // if(handler == 0) { // // TODO aconway 2007-02-20: proper logging. -// cout << "Message returned: " << msg.getData() << endl; +// QPID_LOG(warn, "No handler for message."); // } // else // handler->returned(msg); @@ -407,9 +407,7 @@ void MessageMessageChannel::run() { // /* Orderly shutdown */ // } // catch (const Exception& e) { -// // FIXME aconway 2007-02-20: Report exception to user. -// cout << "client::Message::run() terminated by: " << e.toString() -// << "(" << typeid(e).name() << ")" << endl; +// QPID_LOG(error, e.what()); // } // } } |
