[PATCH 2 of 5] lfs: log information about Internal Server Errors reported in the Batch API
Yuya Nishihara
yuya at tcha.org
Sat Apr 14 07:32:20 UTC 2018
On Fri, 13 Apr 2018 18:04:34 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1523637594 14400
> # Fri Apr 13 12:39:54 2018 -0400
> # Node ID 54c1ab20ed7fbf415d087e6e94ca273d172046e8
> # Parent 1d394ac0efd4aa4f61f428fbac140fe57398f0b8
> lfs: log information about Internal Server Errors reported in the Batch API
> +def _logexception(req):
> + """Write information about the current exception to wsgi.errors."""
> + tb = traceback.format_exc()
> + # We need a native-string newline to poke in the log
> + # message, because we won't get a newline when using an
> + # r-string. This is the easy way out.
> + newline = chr(10)
> + errorlog = req.rawenv[r'wsgi.errors']
> +
> + uri = ''
> + if req.apppath:
> + uri += req.apppath
> + uri += b'/' + req.dispatchpath
> +
> + errorlog.write(r"Exception happened while processing request "
> + r"'%s':%s%s" % (uri.decode('latin-1'), newline, tb))
errorlog is a binary stream as far as I can tell from our codebase. We'll
instead have to convert tb to bytes by pycompat.sysbytes().
More information about the Mercurial-devel
mailing list