aboutsummaryrefslogtreecommitdiffstats
path: root/examples/example6_tracer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/example6_tracer.hpp')
-rw-r--r--examples/example6_tracer.hpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/examples/example6_tracer.hpp b/examples/example6_tracer.hpp
index 8f57f56c..27090cf7 100644
--- a/examples/example6_tracer.hpp
+++ b/examples/example6_tracer.hpp
@@ -1,25 +1,29 @@
/** Tracer used to demonstrate logging communication between client and server.
*/
+class myTracer : public vmime::net::tracer {
-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)
- {
+ 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)
- {
+ void traceSend(const vmime::string& line) {
+
*m_stream << "[" << m_service->getProtocolName() << ":" << m_connectionId
<< "] C: " << line << std::endl;
}
- void traceReceive(const vmime::string& line)
- {
+ void traceReceive(const vmime::string& line) {
+
*m_stream << "[" << m_service->getProtocolName() << ":" << m_connectionId
<< "] S: " << line << std::endl;
}
@@ -31,18 +35,21 @@ private:
const int m_connectionId;
};
-class myTracerFactory : public vmime::net::tracerFactory
-{
+
+class myTracerFactory : public vmime::net::tracerFactory {
+
public:
myTracerFactory(const vmime::shared_ptr <std::ostringstream>& stream)
- : m_stream(stream)
- {
+ : m_stream(stream) {
+
}
- vmime::shared_ptr <vmime::net::tracer> create
- (const vmime::shared_ptr <vmime::net::service>& serv, const int connectionId)
- {
+ 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);
}
@@ -50,4 +57,3 @@ private:
vmime::shared_ptr <std::ostringstream> m_stream;
};
-