blob: 27090cf7352a10e582843b8f419f526f6fda7cad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/** Tracer used to demonstrate logging communication between client and server.
*/
class myTracer : public vmime::net::tracer {
public:
myTracer(
const vmime::shared_ptr <std::ostringstream>& stream,
const vmime::shared_ptr <vmime::net::service>& serv,
const int connectionId
)
: m_stream(stream),
m_service(serv),
m_connectionId(connectionId) {
}
void traceSend(const vmime::string& line) {
*m_stream << "[" << m_service->getProtocolName() << ":" << m_connectionId
<< "] C: " << line << std::endl;
}
void traceReceive(const vmime::string& line) {
*m_stream << "[" << m_service->getProtocolName() << ":" << m_connectionId
<< "] S: " << line << std::endl;
}
private:
vmime::shared_ptr <std::ostringstream> m_stream;
vmime::shared_ptr <vmime::net::service> m_service;
const int m_connectionId;
};
class myTracerFactory : public vmime::net::tracerFactory {
public:
myTracerFactory(const vmime::shared_ptr <std::ostringstream>& stream)
: m_stream(stream) {
}
vmime::shared_ptr <vmime::net::tracer> create(
const vmime::shared_ptr <vmime::net::service>& serv,
const int connectionId
) {
return vmime::make_shared <myTracer>(m_stream, serv, connectionId);
}
private:
vmime::shared_ptr <std::ostringstream> m_stream;
};
|