// ********************************************************************** // // Copyright (c) 2001 // MutableRealms, Inc. // Huntsville, AL, USA // // All Rights Reserved // // ********************************************************************** #include #include #include #include #include #include #include using namespace std; using namespace Ice; using namespace IceInternal; static void printHeader(ostream& s, IntStream& stream) { Byte protVer; stream.read(protVer); s << "\nprotocol version = " << static_cast(protVer); Byte encVer; stream.read(encVer); s << "\nencoding version = " << static_cast(encVer); Byte type; stream.read(type); s << "\nmessage type = " << static_cast(type) << ' '; switch(type) { case requestMsg: { s << "(request)"; break; } case requestBatchMsg: { s << "(request batch)"; break; } case replyMsg: { s << "(reply)"; break; } case closeConnectionMsg: { s << "(close connection)"; break; } default: { s << "(unknown)"; break; } } Int size; stream.read(size); s << "\nmessage size = " << size; } void IceInternal::traceHeader(const char* heading, const IntStream& str, const ::Ice::LoggerPtr& logger, const TraceLevelsPtr& tl) { if (tl->protocol >= 1) { IntStream& stream = const_cast(str); IntStream::Container::iterator p = stream.i; stream.i = stream.b.begin(); ostringstream s; s << heading; printHeader(s, stream); logger->trace(tl->protocolCat, s.str()); stream.i = p; } } void IceInternal::traceRequest(const char* heading, const IntStream& str, const ::Ice::LoggerPtr& logger, const TraceLevelsPtr& tl) { if (tl->protocol >= 1) { IntStream& stream = const_cast(str); IntStream::Container::iterator p = stream.i; stream.i = stream.b.begin(); ostringstream s; s << heading; printHeader(s, stream); Int requestId; stream.read(requestId); s << "\nrequest id = " << requestId; if (requestId == 0) { s << " (oneway)"; } string identity; stream.read(identity); s << "\nidentity = " << identity; string operation; stream.read(operation); s << "\noperation name = " << operation; logger->trace(tl->protocolCat, s.str()); stream.i = p; } } void IceInternal::traceBatchRequest(const char* heading, const IntStream& str, const ::Ice::LoggerPtr& logger, const TraceLevelsPtr& tl) { if (tl->protocol >= 1) { IntStream& stream = const_cast(str); IntStream::Container::iterator p = stream.i; stream.i = stream.b.begin(); ostringstream s; s << heading; printHeader(s, stream); stream.i = p; } } void IceInternal::traceReply(const char* heading, const IntStream& str, const ::Ice::LoggerPtr& logger, const TraceLevelsPtr& tl) { if (tl->protocol >= 1) { IntStream& stream = const_cast(str); IntStream::Container::iterator p = stream.i; stream.i = stream.b.begin(); ostringstream s; s << heading; printHeader(s, stream); Int requestId; stream.read(requestId); s << "\nrequest id = " << requestId; Byte status; stream.read(status); s << "\nreply status = " << static_cast(status) << ' '; switch(static_cast(status)) { case DispatchOK: { s << "(ok)"; break; } case DispatchUserException: { s << "(user exception)"; break; } case DispatchLocationForward: { s << "(location forward)"; break; } case DispatchObjectNotExist: { s << "(object not exist)"; break; } case DispatchOperationNotExist: { s << "(operation not exist)"; break; } case DispatchLocalException: { s << "(local exception)"; break; } case DispatchUnknownException: { s << "(unknown exception)"; break; } default: { s << "(unknown)"; break; } } logger->trace(tl->protocolCat, s.str()); stream.i = p; } }