1 /* $Id: filter_log.cpp,v 1.6 2005-10-25 11:48:30 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() {}
25 void yp2::filter::Log::process(Package &package) const {
29 // getting timestamp for receiving of package
30 boost::posix_time::ptime receive_time
31 = boost::posix_time::microsec_clock::local_time();
33 // scope for locking Ostream
35 boost::mutex::scoped_lock scoped_lock(m_log_mutex);
36 std::cout << receive_time << " " << m_msg;
37 std::cout << " request id=" << package.session().id();
38 std::cout << " close="
39 << (package.session().is_closed() ? "yes" : "no")
41 gdu = package.request().get();
44 ODR odr = odr_createmem(ODR_PRINT);
45 z_GDU(odr, &gdu, 0, 0);
50 // unlocked during move
53 // getting timestamp for sending of package
54 boost::posix_time::ptime send_time
55 = boost::posix_time::microsec_clock::local_time();
57 boost::posix_time::time_duration duration = send_time - receive_time;
59 // scope for locking Ostream
61 boost::mutex::scoped_lock scoped_lock(m_log_mutex);
62 std::cout << send_time << " " << m_msg;
63 std::cout << " response id=" << package.session().id();
64 std::cout << " close="
65 << (package.session().is_closed() ? "yes " : "no ")
66 << "duration=" << duration
68 //<< "duration=" << duration.total_seconds()
69 // << "." << duration.fractional_seconds()
73 gdu = package.response().get();
76 ODR odr = odr_createmem(ODR_PRINT);
77 z_GDU(odr, &gdu, 0, 0);
82 void yp2::filter::Log::set_prefix(const std::string &msg)
87 // defining and initializing static members
88 boost::mutex yp2::filter::Log::m_log_mutex;
93 * indent-tabs-mode: nil
94 * c-file-style: "stroustrup"
96 * vim: shiftwidth=4 tabstop=8 expandtab