+ if (ptr->type != XML_ELEMENT_NODE)
+ continue;
+ if (!strcmp((const char *) ptr->name, "message"))
+ m_msg_config = mp::xml::get_text(ptr);
+ else if (!strcmp((const char *) ptr->name, "filename"))
+ {
+ std::string fname = mp::xml::get_text(ptr);
+ openfile(fname);
+ }
+ else if (!strcmp((const char *) ptr->name, "category"))
+ {
+ const struct _xmlAttr *attr;
+ for (attr = ptr->properties; attr; attr = attr->next)
+ {
+ if (!strcmp((const char *) attr->name,
+ "access"))
+ m_access =
+ mp::xml::get_bool(attr->children, true);
+ else if (!strcmp((const char *) attr->name, "request-apdu"))
+ m_req_apdu = mp::xml::get_bool(attr->children, true);
+ else if (!strcmp((const char *) attr->name, "response-apdu"))
+ m_res_apdu = mp::xml::get_bool(attr->children, true);
+ else if (!strcmp((const char *) attr->name, "apdu"))
+ {
+ m_req_apdu = mp::xml::get_bool(attr->children, true);
+ m_res_apdu = m_req_apdu;
+ }
+ else if (!strcmp((const char *) attr->name,
+ "request-session"))
+ m_req_session =
+ mp::xml::get_bool(attr->children, true);
+ else if (!strcmp((const char *) attr->name,
+ "response-session"))
+ m_res_session =
+ mp::xml::get_bool(attr->children, true);
+ else if (!strcmp((const char *) attr->name,
+ "session"))
+ {
+ m_req_session =
+ mp::xml::get_bool(attr->children, true);
+ m_res_session = m_req_session;
+ }
+ else if (!strcmp((const char *) attr->name,
+ "init-options"))
+ m_init_options =
+ mp::xml::get_bool(attr->children, true);
+ else
+ throw mp::filter::FilterException(
+ "Bad attribute " + std::string((const char *)
+ attr->name));
+ }
+ }
+ else
+ {
+ throw mp::filter::FilterException("Bad element "
+ + std::string((const char *)
+ ptr->name));
+ }
+ }
+}
+
+void yf::Log::Impl::process(mp::Package &package) const
+{
+ Z_GDU *gdu;
+
+ // getting timestamp for receiving of package
+ boost::posix_time::ptime receive_time
+ = boost::posix_time::microsec_clock::local_time();
+
+
+
+ // scope for locking Ostream
+ {
+ boost::mutex::scoped_lock scoped_lock(m_file->m_mutex);
+
+
+ if (m_access)
+ {
+ gdu = package.request().get();
+ 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_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)
+ {
+ gdu = package.request().get();
+ 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)
+ {
+ gdu = package.request().get();
+ 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();