From: Adam Dickmeiss Date: Thu, 16 Oct 2003 13:40:41 +0000 (+0000) Subject: Start work on log options X-Git-Tag: YAZPP.0.7.1 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=a5b1e5653ae9b27e85c6fad5bec42b6fc5156fcb;p=yazpp-moved-to-github.git Start work on log options --- diff --git a/README.txt b/README.txt index 1f83e2b..1c5c937 100644 --- a/README.txt +++ b/README.txt @@ -1,6 +1,6 @@ YAZ++ - A C++ library for YAZ -$Id: README.txt,v 1.12 2003-10-09 16:06:42 adam Exp $ +$Id: README.txt,v 1.13 2003-10-16 13:40:41 adam Exp $ Introduction @@ -8,10 +8,15 @@ Introduction YAZ++ is a C++ layer for YAZ and implements the ANSI Z39.50 protocol for information retrieval (client and server side). -The YAZ homepage is: http://www.indexdata.dk/yaz/ +The YAZ++ homepage is: http://www.indexdata.dk/yaz++/ YAZ++ uses the same license as YAZ - see LICENSE file for details. +Documentation +------------- + +Directory sub contains documentation in HTML and PDF. You can +also read it online at http://www.indexdata.dk/yaz++/ Overview -------- diff --git a/TODO b/TODO index 2e26ceb..f0e3293 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,13 @@ Control the various optimizations with config.. +Control the various logging facilities APDU, etc. in XML configuration. + Handle invalidate sessions (-1 hit, control-number search). Live status (via search, present). -Documentation update. - SRW/SRU. -Threading. +Possible threading. diff --git a/configure.in b/configure.in index 4649b05..84a7c3c 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_INIT(configure.in) -AM_INIT_AUTOMAKE("yaz++",0.7) +AM_INIT_AUTOMAKE("yaz++",0.7.1) AC_PROG_CC AC_PROG_CPP diff --git a/include/yaz++/proxy.h b/include/yaz++/proxy.h index 2fbdc46..cb96fc1 100644 --- a/include/yaz++/proxy.h +++ b/include/yaz++/proxy.h @@ -2,7 +2,7 @@ * Copyright (c) 1998-2003, Index Data. * See the file LICENSE for details. * - * $Id: proxy.h,v 1.17 2003-10-16 08:28:10 adam Exp $ + * $Id: proxy.h,v 1.18 2003-10-16 13:40:41 adam Exp $ */ #include @@ -18,6 +18,9 @@ class Yaz_Proxy; #define MAX_ZURL_PLEX 10 +#define PROXY_LOG_APDU 1 +#define PROXY_LOG_REQ 1 + struct Yaz_RecordCache_Entry; class YAZ_EXPORT Yaz_ProxyConfig { @@ -37,14 +40,15 @@ public: int *max_clients, int *keepalive_limit_bw, int *keepalive_limit_pdu, - int *pre_init); + int *pre_init, + int *log_mask); void get_target_info(const char *name, const char **url, int *limit_bw, int *limit_pdu, int *limit_req, int *target_idletime, int *client_idletime, int *max_clients, int *keepalive_limit_bw, int *keepalive_limit_pdu, - int *pre_init); + int *pre_init, int *log_mask); int check_query(ODR odr, const char *name, Z_Query *query, char **addinfo); int check_syntax(ODR odr, const char *name, @@ -58,7 +62,7 @@ private: int *limit_bw, int *limit_pdu, int *limit_req, int *target_idletime, int *client_idletime, int *keepalive_limit_bw, int *keepalive_limit_pdu, - int *pre_init); + int *pre_init, int *log_mask); void return_limit(xmlNodePtr ptr, int *limit_bw, int *limit_pdu, int *limit_req); int check_type_1(ODR odr, xmlNodePtr ptr, Z_RPNQuery *query, diff --git a/src/yaz-proxy-config.cpp b/src/yaz-proxy-config.cpp index 54ddd59..2d5d22e 100644 --- a/src/yaz-proxy-config.cpp +++ b/src/yaz-proxy-config.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2003, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy-config.cpp,v 1.9 2003-10-13 19:16:29 adam Exp $ + * $Id: yaz-proxy-config.cpp,v 1.10 2003-10-16 13:40:41 adam Exp $ */ #include @@ -117,7 +117,8 @@ void Yaz_ProxyConfig::return_target_info(xmlNodePtr ptr, int *client_idletime, int *keepalive_limit_bw, int *keepalive_limit_pdu, - int *pre_init) + int *pre_init, + int *log_mask) { *pre_init = 0; int no_url = 0; @@ -125,6 +126,30 @@ void Yaz_ProxyConfig::return_target_info(xmlNodePtr ptr, for (; ptr; ptr = ptr->next) { if (ptr->type == XML_ELEMENT_NODE + && !strcmp((const char *) ptr->name, "log")) + { + const char *v = get_text(ptr); + *log_mask = 0; + while (v && *v) + { + const char *cp = v; + while (*cp && *cp != ',' && !isspace(*cp)) + cp++; + size_t len = cp - v; + if (len == 4 && !memcmp(v, "apdu", 4)) + *log_mask |= PROXY_LOG_APDU; + if (len == 3 && !memcmp(v, "req", 3)) + *log_mask |= PROXY_LOG_REQ; + if (isdigit(*v)) + *log_mask |= atoi(v); + if (*cp == ',') + cp++; + while (*cp && isspace(*cp)) + cp++; + v = cp; + } + } + if (ptr->type == XML_ELEMENT_NODE && !strcmp((const char *) ptr->name, "preinit")) { const char *v = get_text(ptr); @@ -463,7 +488,8 @@ int Yaz_ProxyConfig::get_target_no(int no, int *max_clients, int *keepalive_limit_bw, int *keepalive_limit_pdu, - int *pre_init) + int *pre_init, + int *log_mask) { #if HAVE_XML2 xmlNodePtr ptr; @@ -488,7 +514,7 @@ int Yaz_ProxyConfig::get_target_no(int no, return_target_info(ptr, url, limit_bw, limit_pdu, limit_req, target_idletime, client_idletime, keepalive_limit_bw, keepalive_limit_pdu, - pre_init); + pre_init, log_mask); return 1; } i++; @@ -507,7 +533,8 @@ void Yaz_ProxyConfig::get_target_info(const char *name, int *max_clients, int *keepalive_limit_bw, int *keepalive_limit_pdu, - int *pre_init) + int *pre_init, + int *log_mask) { #if HAVE_XML2 xmlNodePtr ptr; @@ -543,7 +570,7 @@ void Yaz_ProxyConfig::get_target_info(const char *name, return_target_info(ptr, url, limit_bw, limit_pdu, limit_req, target_idletime, client_idletime, keepalive_limit_bw, keepalive_limit_pdu, - pre_init); + pre_init, log_mask); } #else *url = name; diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 853d5ee..921d8e5 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2003, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.cpp,v 1.60 2003-10-16 08:28:10 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.61 2003-10-16 13:40:41 adam Exp $ */ #include @@ -249,17 +249,20 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) proxy_host = m_default_target; } int client_idletime = -1; - int pre_init = 0; url[0] = m_default_target; url[1] = 0; if (cfg) + { + int pre_init = 0; + int log_mask = 0; cfg->get_target_info(proxy_host, url, &m_bw_max, &m_pdu_max, &m_max_record_retrieve, &m_target_idletime, &client_idletime, &parent->m_max_clients, &m_keepalive_limit_bw, &m_keepalive_limit_pdu, - &pre_init); + &pre_init, &log_mask); + } if (client_idletime != -1) { m_client_idletime = client_idletime; @@ -1276,6 +1279,7 @@ void Yaz_Proxy::pre_init() int max_clients; int keepalive_limit_bw, keepalive_limit_pdu; int pre_init; + int log_mask = 0; Yaz_ProxyConfig *cfg = check_reconfigure(); @@ -1287,7 +1291,7 @@ void Yaz_Proxy::pre_init() &max_clients, &keepalive_limit_bw, &keepalive_limit_pdu, - &pre_init) ; i++) + &pre_init, &log_mask) ; i++) { if (pre_init) {