changeset 56:7293dbfe54a4

improve logging and http error response bodies Ignore-this: 154bc7f09a24392d1ae297650f13d0f
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 30 May 2019 08:18:12 +0000
parents 54664942cc61
children bcaba1620128
files rdfdb/graphfile.py rdfdb/patchreceiver.py rdfdb/patchsender.py rdfdb/service.py
diffstat 4 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rdfdb/graphfile.py	Thu May 30 08:17:11 2019 +0000
+++ b/rdfdb/graphfile.py	Thu May 30 08:18:12 2019 +0000
@@ -249,7 +249,7 @@
         going towards a text file editor
         
         """
-        log.info("%s dirty, needs write", self.path)
+        log.debug("%s dirty, needs write", self.path)
 
         self.graphToWrite = graph
         if self.writeCall:
--- a/rdfdb/patchreceiver.py	Thu May 30 08:17:11 2019 +0000
+++ b/rdfdb/patchreceiver.py	Thu May 30 08:18:12 2019 +0000
@@ -63,7 +63,10 @@
             log.debug("received patch -%d +%d" %
                       (len(p.delGraph), len(p.addGraph)))
             cb(p)
-        except:
+        except Exception as e:
+            self.set_status(500)
+            # a string that will look good in rdfdb's log
+            self.write(repr(e))
             traceback.print_exc()
             raise
 
--- a/rdfdb/patchsender.py	Thu May 30 08:17:11 2019 +0000
+++ b/rdfdb/patchsender.py	Thu May 30 08:18:12 2019 +0000
@@ -7,7 +7,7 @@
 
 from rdfdb.patch import Patch
 
-log = logging.getLogger('syncedgraph')
+log = logging.getLogger('patchsender')
 
 SendResult = defer.Deferred  # to None
 
@@ -122,8 +122,10 @@
     def putDone(done):
         if not str(done.code).startswith('2'):
             def fail(content):
-                raise ValueError("sendPatch request failed %s: %s" %
-                                 (done.code, content))
+                log.warn(f"Sent patch to {putUri}:")
+                log.warn(str(patch))
+                log.warn(f"Receiver failed {done.code} {content}")
+                raise ValueError("sendPatch failed")
             return done.content().addCallback(fail)
 
         dt = 1000 * (time.time() - sendTime)
--- a/rdfdb/service.py	Thu May 30 08:17:11 2019 +0000
+++ b/rdfdb/service.py	Thu May 30 08:18:12 2019 +0000
@@ -85,8 +85,9 @@
 
 def sendGraphToClient(graph, client: Union[Client, WsClient]) -> None:
     """send the client the whole graph contents"""
-    log.info("sending all graphs to %r" % client)
+    log.info("sending all graphs to %r..." % client)
     client.sendPatch(Patch(addQuads=graph.quads(ALLSTMTS), delQuads=[]))
+    log.info("...sent.")
 
 
 class WatchedFiles(object):