Facility disable/logging of POSTed content PAZ-1027
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 31 Aug 2015 09:31:56 +0000 (11:31 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 31 Aug 2015 09:31:56 +0000 (11:31 +0200)
Log level "post" controls whether POSTed content is logged. This
is enabled by default. To disable, use -v -post on the command
line.

src/http.c
src/pazpar2.c

index 1bbd4a1..e6d883a 100644 (file)
@@ -81,6 +81,7 @@ struct http_buf
     struct http_buf *next;
 };
 
+static int log_level_post = 0;
 
 static void proxy_io(IOCHAN i, int event);
 static struct http_channel *http_channel_create(http_server_t http_server,
@@ -959,8 +960,8 @@ static void http_io(IOCHAN i, int event)
                         hc->request->path,
                         *hc->request->search ? "?" : "",
                         hc->request->search);
-                if (hc->request->content_buf)
-                    yaz_log(YLOG_LOG, "%s", hc->request->content_buf);
+                if (hc->request->content_buf && log_level_post)
+                    yaz_log(log_level_post, "%s", hc->request->content_buf);
                 if (http_weshouldproxy(hc->request))
                     http_proxy(hc->request);
                 else
@@ -1452,8 +1453,10 @@ http_server_t http_server_create(void)
     hs->proxy_addr = 0;
     hs->ref_count = 1;
     hs->http_sessions = 0;
-
     hs->record_file = 0;
+
+    log_level_post = yaz_log_module_level("post");
+
     return hs;
 }
 
index b3928aa..d56daba 100644 (file)
@@ -120,6 +120,7 @@ static int sc_main(
 #endif
 
     yaz_log_init_prefix("pazpar2");
+    yaz_log_init_level(yaz_log_mask_str("post"));
     yaz_log_xml_errors(0, YLOG_WARN);
 
     yaz_enable_panic_backtrace(argv[0]);