Use yaz_log to print info about events; not printf
[yaz-moved-to-github.git] / zoom / zoomsh.c
index 8469ce4..8c06f12 100644 (file)
@@ -12,6 +12,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <yaz/wrbuf.h>
+#include <yaz/log.h>
 
 #if HAVE_READLINE_READLINE_H
 #include <readline/readline.h> 
 
 #define MAX_CON 100
 
+static void process_events(ZOOM_connection *c)
+{
+    int i;
+
+    yaz_log(YLOG_DEBUG, "process_events");
+    while ((i = ZOOM_event(MAX_CON, c)) != 0)
+    {
+        int peek = ZOOM_connection_peek_event(c[i-1]);
+        int event = ZOOM_connection_last_event(c[i-1]);
+        yaz_log(YLOG_DEBUG, "no = %d peek = %d event = %d %s", i-1,
+                peek,
+                event,
+                ZOOM_get_event_str(event));
+    }
+}
+
 static int next_token(const char **cpp, const char **t_start)
 {
     int len = 0;
@@ -249,8 +266,7 @@ static void cmd_show(ZOOM_connection *c, ZOOM_resultset *r,
 
     for (i = 0; i < MAX_CON; i++)
         ZOOM_resultset_records(r[i], 0, start, count);
-    while (ZOOM_event(MAX_CON, c))
-        ;
+    process_events(c);
 
     for (i = 0; i < MAX_CON; i++)
     {
@@ -318,14 +334,7 @@ static void cmd_facets(ZOOM_connection *c, ZOOM_resultset *r,
     if (render_str)
         type = wrbuf_cstr(render_str);
 
-    /*
-    for (i = 0; i < MAX_CON; i++) {
-        int num_facets = ZOOM_resultset_facet_size(r[i]);
-        ZOOM_resultset_records(r[i], 0, start, count);
-    }
-    */
-    while (ZOOM_event(MAX_CON, c))
-        ;
+    process_events(c);
 
     for (i = 0; i < MAX_CON; i++)
     {
@@ -371,8 +380,7 @@ static void cmd_ext(ZOOM_connection *c, ZOOM_resultset *r,
             p[i] = 0;
     }
 
-    while (ZOOM_event(MAX_CON, c))
-        ;
+    process_events(c);
 
     for (i = 0; i<MAX_CON; i++)
     {
@@ -442,8 +450,7 @@ static void cmd_search(ZOOM_connection *c, ZOOM_resultset *r,
     }
     ZOOM_query_destroy(s);
 
-    while (ZOOM_event(MAX_CON, c))
-        ;
+    process_events(c);
 
     for (i = 0; i<MAX_CON; i++)
     {
@@ -501,8 +508,8 @@ static void cmd_scan(ZOOM_connection *c, ZOOM_resultset *r,
     }
     ZOOM_query_destroy(query);
 
-    while (ZOOM_event(MAX_CON, c))
-        ;
+    process_events(c);
+
     for (i = 0; i<MAX_CON; i++)
     {
         int error;
@@ -545,8 +552,7 @@ static void cmd_sort(ZOOM_connection *c, ZOOM_resultset *r,
         if (r[i])
             ZOOM_resultset_sort(r[i], "yaz", sort_spec);
     }
-    while (ZOOM_event(MAX_CON, c))
-        ;
+    process_events(c);
 }
 
 static void cmd_help(ZOOM_connection *c, ZOOM_resultset *r,