Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
log: Add single line summary for errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
rram committed Mar 1, 2013
1 parent 94abab2 commit da1e71f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion r2/r2/lib/log.py
Expand Up @@ -24,7 +24,7 @@

from datetime import datetime

from pylons import g
from pylons import g, c, request
from weberror.reporter import Reporter


Expand Down Expand Up @@ -122,6 +122,19 @@ class LoggingErrorReporter(Reporter):
"""ErrorMiddleware-compatible reporter that writes exceptions to g.log."""

def report(self, exc_data):
# exception_formatted is the output of traceback.format_exception_only
exception = exc_data.exception_formatted[-1].strip()

# This is still within the RegistryManager middleware
fullpath = request.environ.get('FULLPATH', request.path)
uid = '-'
if c.user_is_loggedin:
uid = c.user._id

# First emit a single-line summary. This is great for grepping the
# streaming log for errors.
g.log.error("E: %s U: %s FP: %s", exception, uid, fullpath)

text, extra = self.format_text(exc_data)
# TODO: send this all in one burst so that error reports aren't
# interleaved / individual lines aren't dropped. doing so will take
Expand Down

0 comments on commit da1e71f

Please sign in to comment.