API Reference

Make good log output easier.

class sprockets.logging.ContextFilter(name='', properties=None)

Ensures that properties exist on a LogRecord.

Parameters:properties (list|None) – optional list of properties that will be added to LogRecord instances if they are missing

This filter implementation will ensure that a set of properties exists on every log record which means that you can always refer to custom properties in a format string. Without this, referring to a property that is not explicitly passed in will result in an ugly KeyError exception.

class sprockets.logging.JSONRequestFormatter(fmt=None, datefmt=None)

Instead of spitting out a “human readable” log line, this outputs the log data as JSON.

extract_exc_record(typ, val, tb)

Create a JSON representation of the traceback given the records exc_info

  • typ (Exception) – Exception type of the exception being handled
  • instance val (Exception) – instance of the Exception class
  • tb (traceback) – traceback object with the call stack
Return type:



Return the log data as JSON

Parameters:logging.LogRecord (record) – The record to format
Return type:str

Return the frame object for the caller’s stack frame.


Assigned when creating a tornado.web.Application instance by passing the method as the log_function argument:

app = tornado.web.Application([('/', RequestHandler)],