+ // getting timestamp for receiving of package
+ boost::posix_time::ptime receive_time
+ = boost::posix_time::microsec_clock::local_time();
+
+ // scope for session lock
+ {
+ boost::mutex::scoped_lock scoped_lock(m_session_mutex);
+
+ if (gdu && gdu->which == Z_GDU_Z3950)
+ {
+ Z_APDU *apdu_req = gdu->u.z3950;
+ if (apdu_req->which == Z_APDU_initRequest)
+ {
+ Z_InitRequest *req = apdu_req->u.initRequest;
+ Z_IdAuthentication *a = req->idAuthentication;
+ if (a)
+ {
+ if (a->which == Z_IdAuthentication_idPass)
+ user = a->u.idPass->userId;
+ else if (a->which == Z_IdAuthentication_open)
+ user = a->u.open;
+
+ m_sessions[package.session()] = user;
+ }
+ }
+ }
+ std::map<mp::Session,std::string>::iterator it =
+ m_sessions.find(package.session());
+ if (it != m_sessions.end())
+ user = it->second;
+
+ if (package.session().is_closed())
+ m_sessions.erase(package.session());
+ }
+ // scope for locking Ostream
+ {
+ boost::mutex::scoped_lock scoped_lock(m_file->m_mutex);
+
+ if (m_access)
+ {
+ if (gdu)
+ {
+ m_file->out
+ //<< receive_time << " "
+ //<< to_iso_string(receive_time) << " "
+ << to_iso_extended_string(receive_time) << " "
+ << m_msg_config << " "
+ << package << " "
+ << "000000.000000" << " "
+ << *gdu
+ << "\n";
+ }
+ }
+
+ if (m_user_access)
+ {
+ if (gdu)
+ {
+ m_file->out
+ //<< receive_time << " "
+ //<< to_iso_string(receive_time) << " "
+ << to_iso_extended_string(receive_time) << " "
+ << m_msg_config << " " << user << " "
+ << package << " "
+ << "000000.000000" << " "
+ << *gdu
+ << "\n";
+ }
+ }
+
+ if (m_req_session)
+ {
+ m_file->out << receive_time << " " << m_msg_config;
+ m_file->out << " request id=" << package.session().id();
+ m_file->out << " close="
+ << (package.session().is_closed() ? "yes" : "no")
+ << "\n";
+ }
+
+ if (m_init_options)
+ {
+ if (gdu && gdu->which == Z_GDU_Z3950 &&
+ gdu->u.z3950->which == Z_APDU_initRequest)
+ {
+ m_file->out << receive_time << " " << m_msg_config;
+ m_file->out << " init options:";
+ yaz_init_opt_decode(gdu->u.z3950->u.initRequest->options,
+ option_write, m_file.get());
+ m_file->out << "\n";
+ }
+ }
+
+ if (m_req_apdu)
+ {
+ if (gdu)
+ {
+ mp::odr odr(ODR_PRINT);
+ odr_set_stream(odr, m_file.get(), stream_write, 0);
+ z_GDU(odr, &gdu, 0, 0);
+ }
+ }
+ m_file->out.flush();
+ }
+
+ // unlocked during move
+ package.move();