+ // getting timestamp for sending of package
+ boost::posix_time::ptime send_time
+ = boost::posix_time::microsec_clock::local_time();
+
+ boost::posix_time::time_duration duration = send_time - receive_time;
+
+ // scope for locking Ostream
+ {
+ boost::mutex::scoped_lock scoped_lock(m_p->m_file->m_mutex);
+
+ if (m_p->m_access)
+ {
+ gdu = package.response().get();
+ if (gdu)
+ {
+ m_p->m_file->out
+ //<< send_time << " "
+ //<< to_iso_string(send_time) << " "
+ << to_iso_extended_string(send_time) << " "
+ << m_p->m_msg_config << " "
+ << package << " "
+ << to_iso_string(duration) << " "
+ << *gdu
+ << "\n";
+ }
+ }
+
+ if (m_p->m_res_session)
+ {
+ m_p->m_file->out << send_time << " " << m_p->m_msg_config;
+ m_p->m_file->out << " response id=" << package.session().id();
+ m_p->m_file->out << " close="
+ << (package.session().is_closed() ? "yes " : "no ")
+ << "duration=" << duration
+ << "\n";
+ }
+
+ if (m_p->m_init_options)
+ {
+ gdu = package.response().get();
+ if (gdu && gdu->which == Z_GDU_Z3950 &&
+ gdu->u.z3950->which == Z_APDU_initResponse)
+ {
+ m_p->m_file->out << receive_time << " " << m_p->m_msg_config;
+ m_p->m_file->out << " init options:";
+ yaz_init_opt_decode(gdu->u.z3950->u.initResponse->options,
+ option_write, m_p->m_file.get());
+ m_p->m_file->out << "\n";
+ }
+ }
+
+ if (m_p->m_res_apdu)
+ {
+ gdu = package.response().get();
+ if (gdu)
+ {
+ mp::odr odr(ODR_PRINT);
+ odr_set_stream(odr, m_p->m_file.get(), stream_write, 0);
+ z_GDU(odr, &gdu, 0, 0);
+ }
+ }
+
+ m_p->m_file->out.flush();
+ }
+}
+
+yf::Log::LFile::LFile(std::string fname) :
+ m_fname(fname), fout(fname.c_str()), out(fout)
+{
+}
+
+yf::Log::LFile::LFile(std::string fname, std::ostream &use_this) :
+ m_fname(fname), out(use_this)
+{
+}
+
+void yf::Log::Rep::openfile(const std::string &fname)
+{
+ std::list<LFilePtr>::const_iterator it = filter_log_files.begin();
+ for (; it != filter_log_files.end(); it++)
+ {
+ if ((*it)->m_fname == fname)
+ {
+ m_file = *it;
+ return;
+ }
+ }
+ // open stdout for empty file
+ LFilePtr newfile(fname.length() == 0
+ ? new LFile(fname, std::cout)
+ : new LFile(fname));
+ filter_log_files.push_back(newfile);
+ m_file = newfile;
+}
+
+void yf::Log::configure(const xmlNode *ptr)
+{
+ for (ptr = ptr->children; ptr; ptr = ptr->next)