Mercurial > code > home > repos > light9
changeset 986:c50b7d6fcc4e
don't log huge json patch bodies, but do print how big they are and how long they took
Ignore-this: ba479815d0e5bd45247ed8c32a932010
author | drewp@bigasterisk.com |
---|---|
date | Sun, 16 Jun 2013 06:47:58 +0000 |
parents | ee84e1fbca73 |
children | 5945e32d992d |
files | light9/rdfdb/patchsender.py |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/rdfdb/patchsender.py Sun Jun 16 04:03:54 2013 +0000 +++ b/light9/rdfdb/patchsender.py Sun Jun 16 06:47:58 2013 +0000 @@ -1,4 +1,4 @@ -import logging +import logging, time import cyclone.httpclient from twisted.internet import defer log = logging.getLogger('syncedgraph') @@ -96,12 +96,17 @@ kwargs will become extra attributes in the toplevel json object """ + t1 = time.time() body = patch.makeJsonRepr(kw) - log.debug("send body: %r", body) + jsonTime = time.time() - t1 + intro = body[:200] + if len(body) > 200: + intro = intro + "..." + log.debug("send body (rendered %.1fkB in %.1fms): %s", len(body) / 1024, jsonTime * 1000, intro) def putDone(done): if not str(done.code).startswith('2'): raise ValueError("sendPatch request failed %s: %s" % (done.code, done.body)) - log.debug("sendPatch finished, response: %s" % done.body) + log.debug("sendPatch finished, response: %r" % done.body) return done return cyclone.httpclient.fetch(