comparison GEMBASSY-1.0.3/gsoap/extras/logging.cpp @ 0:8300eb051bea draft

Initial upload
author ktnyt
date Fri, 26 Jun 2015 05:19:29 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8300eb051bea
1 // logging.cpp
2 //
3 // Place this file in the same direcory as stdsoap2.h
4 // Requires soapdefs.h (compile stdsoap2.cpp with -DWITH_SOAPDEFS_H
5 // and -DDEBUG_CALLBACKS)
6 //
7 // Runtime/Customer logging by Mike Helmick
8 // Copyright (c) 2002 - Mike Helmick. Convergys IMG. All Rights Reserved.
9 // This contributed code is covered under the MPL 1.1 license
10
11 #include "stdsoap2.h" // includes "soapdefs.h" when compiled with -DWITH_SOAPDEFS_H
12
13 void soap_recv_callback(struct soap*, const char*, size_t len);
14 void soap_sent_callback(struct soap*, const char*, size_t len);
15 void soap_test_callback(struct soap*, const char*, size_t len);
16
17 void
18 soap_dispatch_callback(struct soap *soap, int idx, const char *msg, size_t len)
19 { if (!soap->user)
20 { // you can set stuff up here, streams etc.
21 // soap->user is used to pass user-defined data
22 // soap->user is never set nor cleared by gSOAP
23 soap->user = (void*)&cout;
24 // don't forget to clean up the streams in the main code
25 // (before discarding the soap runtime environment)
26 }
27 switch (idx)
28 { case SOAP_INDEX_RECV:
29 soap_recv_callback(soap, msg, len);
30 break;
31 case SOAP_INDEX_SENT:
32 soap_sent_callback(soap, msg, len);
33 break;
34 case SOAP_INDEX_TEST:
35 soap_test_callback(soap, msg, len);
36 break;
37 }
38 }
39
40 // Note: 'msg' is not 0-terminated!
41 void
42 soap_recv_callback(struct soap *soap, const char *msg, size_t len)
43 { ostream& os = *(ostream*)soap->user;
44 os << endl
45 << "Received:" << endl
46 << "----------------------------------------" << endl;
47 os.write(msg, len);
48 os << "----------------------------------------" << endl;
49 }
50
51 void
52 soap_sent_callback(struct soap *soap, const char *msg, size_t len)
53 { ostream& os = *(ostream*)soap->user;
54 os << endl
55 << "Sent:" << endl
56 << "----------------------------------------" << endl;
57 os.write(msg, len);
58 os << "----------------------------------------" << endl;
59 }
60
61 void
62 soap_test_callback(struct soap *soap, const char *msg, size_t len)
63 { (*(ostream*)soap->user << "Trace: ").write(msg, len);
64 }