/// get function - right val in assignment
Session session() const;
- void log(const char *module, int level, const char *fmt, ...) const;
+ void log(const char *module, int level, const char *fmt, ...);
+
+ void reset_log(std::string &res);
+
+ class PackageLogger;
+ typedef boost::shared_ptr<PackageLogger> PackageLoggerPtr;
+
private:
Session m_session;
Origin m_origin;
RoutePos *m_route_pos;
- //int m_data;
+ PackageLoggerPtr p_logger;
yazpp_1::GDU m_request_gdu;
yazpp_1::GDU m_response_gdu;
};
}
-
-
#endif
/*
* Local variables:
YAZ_SRW_UNSUPP_OPERATION, "unknown");
}
+
+ std::string l;
+ package.reset_log(l);
+ if (l.length())
+ {
+ WRBUF w = wrbuf_alloc();
+
+ wrbuf_puts(w, "<log>\n");
+ wrbuf_xmlputs(w, l.c_str());
+ wrbuf_puts(w, "</log>");
+
+ sru_pdu_res->extraResponseData_len = wrbuf_len(w);
+ sru_pdu_res->extraResponseData_buf = odr_strdup(odr_en, wrbuf_cstr(w));
+ wrbuf_destroy(w);
+ }
+
// build and send SRU response
mp_util::build_sru_response(package, odr_en, soap,
sru_pdu_res, charset, stylesheet);
namespace mp = metaproxy_1;
+namespace metaproxy_1 {
+ class Package::PackageLogger : boost::noncopyable {
+ friend class Package;
+ std::string str;
+ };
+}
+
mp::Package::Package()
- : m_route_pos(0)
+ : m_route_pos(0), p_logger(new PackageLogger)
{
}
mp::Package::Package(mp::Session &session, const mp::Origin &origin)
: m_session(session), m_origin(origin),
- m_route_pos(0)
+ m_route_pos(0), p_logger(new PackageLogger)
{
}
{
delete m_route_pos;
m_route_pos = p.m_route_pos->clone();
+ p_logger = p.p_logger;
return *this;
}
return os;
}
-void mp::Package::log(const char *module, int level, const char *fmt, ...) const
+void mp::Package::log(const char *module, int level, const char *fmt, ...)
{
char buf[4096];
va_list ap;
va_start(ap, fmt);
- yaz_vsnprintf(buf, sizeof(buf)-30, fmt, ap);
+ buf[0] = ' ';
+ yaz_vsnprintf(buf + 1, sizeof(buf)-30, fmt, ap);
std::ostringstream os;
- os << module << " " << *this << " " << buf;
+ os << module << " " << *this << buf;
va_end(ap);
yaz_log(level, "%s", os.str().c_str());
+
+ p_logger->str += std::string(module) + std::string(buf) + std::string("\n");
}
-
+
+void mp::Package::reset_log(std::string &res)
+{
+ res = p_logger->str;
+ p_logger->str.clear();
+}
+
/*
* Local variables:
* c-basic-offset: 4