MPSPARQL-19: Clean up logging
authorHeikki Levanto <heikki@indexdata.dk>
Tue, 12 May 2015 12:37:15 +0000 (14:37 +0200)
committerHeikki Levanto <heikki@indexdata.dk>
Tue, 12 May 2015 12:37:15 +0000 (14:37 +0200)
Log the queries once, do not log the HTTP req/resp, but do
log responses in case of errors

bibframe/triplestore.xml
src/filter_sparql.cpp

index 415e66a..2686042 100644 (file)
 
             <!-- Find the work that has a given Instance -->
             <index type="bf.instance">
-                %v_inst bf:instanceOf ?thing FILTER ( %v_inst = %u) 
+                %v_inst bf:instanceOf ?thing FILTER ( %v_inst = %u)
             </index>
-            
+
             <!-- Find all works that refer to the given uri -->
             <!-- useful after finding uris in the "small" bases -->
             <!-- direct references only -->
 
     <filter type="log">
         <message>http</message>
+<!--
         <category apdu="true"/>
+-->
     </filter>
-
     <filter type="http_client">
         <x-forwarded-for>true</x-forwarded-for>
     </filter>
index 638d2ba..d9b51eb 100644 (file)
@@ -549,7 +549,6 @@ Z_Records *yf::SPARQL::Session::fetch(
                         package.log("sparql", YLOG_LOG,
                             "fetch uri:%s", uri.c_str() );
                     }
-                    //yaz_log(YLOG_LOG, "query=%s", query.c_str());
                     error = invoke_sparql(package, query.c_str(),
                                           it->conf, w);
                 }
@@ -616,7 +615,7 @@ int yf::SPARQL::Session::invoke_sparql(mp::Package &package,
     gdu->u.HTTP_Request->content_buf = path;
     gdu->u.HTTP_Request->content_len = strlen(path);
 
-    yaz_log(YLOG_LOG, "sparql: HTTP request\n%s", sparql_query);
+    yaz_log(YLOG_DEBUG, "sparql: HTTP request\n%s", sparql_query);
 
     http_package.request() = gdu;
     http_package.move();
@@ -630,8 +629,14 @@ int yf::SPARQL::Session::invoke_sparql(mp::Package &package,
     }
     else if (gdu_resp->u.HTTP_Response->code != 200)
     {
+        Z_HTTP_Response *resp = gdu_resp->u.HTTP_Response;
         wrbuf_printf(w, "sparql: HTTP error %d from backend",
-                     gdu_resp->u.HTTP_Response->code);
+                     resp->code);
+        package.log("sparql", YLOG_LOG,
+            "HTTP error %d from backend ",
+            resp->code );
+        package.log("sparql", YLOG_LOG,
+            "%.*s" , resp->content_len, resp->content_buf );
         return YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
     }
     Z_HTTP_Response *resp = gdu_resp->u.HTTP_Response;
@@ -681,7 +686,7 @@ Z_APDU *yf::SPARQL::Session::search(mp::Package &package,
             result.doc = doc;
             result.conf = conf;
             fset->results.push_back(result);
-            yaz_log(YLOG_LOG, "saving sparql result xmldoc=%p", doc);
+            yaz_log(YLOG_DEBUG, "saving sparql result xmldoc=%p", doc);
 
             get_result(result.doc, &fset->hits, -1, 0);
             m_frontend_sets[req->resultSetName] = fset;