Added logging of CQL/PQF queries for ZOOM-based code
[pazpar2-moved-to-github.git] / src / client.c
index edb5156..ff3c0fb 100644 (file)
@@ -35,7 +35,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <unistd.h>
 #endif
 #include <signal.h>
-#include <ctype.h>
 #include <assert.h>
 
 #include <yaz/marcdisp.h>
@@ -457,13 +456,17 @@ void client_start_search(struct client *cl)
 
     if (cl->cqlquery)
     {
+        yaz_log(YLOG_LOG, "Search %s CQL: %s", sdb->database->url, cl->cqlquery);
         ZOOM_query q = ZOOM_query_create();
         ZOOM_query_cql(q, cl->cqlquery);
         rs = ZOOM_connection_search(link, q);
         ZOOM_query_destroy(q);
     }
     else
+    {
+        yaz_log(YLOG_LOG, "Search %s PQF: %s", sdb->database->url, cl->pquery);
         rs = ZOOM_connection_search_pqf(link, cl->pquery);
+    }
     connection_set_resultset(co, rs);
     connection_continue(co);
 }
@@ -592,6 +595,7 @@ int client_parse_query(struct client *cl, const char *query)
     int cerror, cpos;
     CCL_bibset ccl_map = prepare_cclmap(cl);
     const char *sru = session_setting_oneval(sdb, PZ_SRU);
+    const char *pqf_prefix = session_setting_oneval(sdb, PZ_PQF_PREFIX);
 
     if (!ccl_map)
         return -1;
@@ -606,6 +610,11 @@ int client_parse_query(struct client *cl, const char *query)
         return -1;
     }
     wrbuf_rewind(se->wrbuf);
+    if (*pqf_prefix)
+    {
+        wrbuf_puts(se->wrbuf, pqf_prefix);
+        wrbuf_puts(se->wrbuf, " ");
+    }
     ccl_pquery(se->wrbuf, cn);
     xfree(cl->pquery);
     cl->pquery = xstrdup(wrbuf_cstr(se->wrbuf));