1 /* $Id: filter_log.cpp,v 1.7 2005-10-25 16:01:36 adam Exp $
2 Copyright (c) 2005, Index Data.
12 #include "package.hpp"
14 #include "filter_log.hpp"
19 #include <boost/date_time/posix_time/posix_time.hpp>
23 yp2::filter::Log::Log() {}
24 yp2::filter::Log::Log(const std::string &msg) : m_msg(msg) {}
26 void yp2::filter::Log::process(Package &package) const {
30 // getting timestamp for receiving of package
31 boost::posix_time::ptime receive_time
32 = boost::posix_time::microsec_clock::local_time();
34 // scope for locking Ostream
36 boost::mutex::scoped_lock scoped_lock(m_log_mutex);
37 std::cout << receive_time << " " << m_msg;
38 std::cout << " request id=" << package.session().id();
39 std::cout << " close="
40 << (package.session().is_closed() ? "yes" : "no")
42 gdu = package.request().get();
45 ODR odr = odr_createmem(ODR_PRINT);
46 z_GDU(odr, &gdu, 0, 0);
51 // unlocked during move
54 // getting timestamp for sending of package
55 boost::posix_time::ptime send_time
56 = boost::posix_time::microsec_clock::local_time();
58 boost::posix_time::time_duration duration = send_time - receive_time;
60 // scope for locking Ostream
62 boost::mutex::scoped_lock scoped_lock(m_log_mutex);
63 std::cout << send_time << " " << m_msg;
64 std::cout << " response id=" << package.session().id();
65 std::cout << " close="
66 << (package.session().is_closed() ? "yes " : "no ")
67 << "duration=" << duration
69 //<< "duration=" << duration.total_seconds()
70 // << "." << duration.fractional_seconds()
74 gdu = package.response().get();
77 ODR odr = odr_createmem(ODR_PRINT);
78 z_GDU(odr, &gdu, 0, 0);
83 // defining and initializing static members
84 boost::mutex yp2::filter::Log::m_log_mutex;
89 * indent-tabs-mode: nil
90 * c-file-style: "stroustrup"
92 * vim: shiftwidth=4 tabstop=8 expandtab