API Reference¶
Make good log output easier.
ContextFilteradds fixed properties to a log recordJSONRequestFormatterformats log records as JSON output- :method:`tornado_log_function` is for use as the
:class`tornado.web.Application.log_function` in conjunction with
JSONRequestFormatterto output log lines as JSON.
-
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
KeyErrorexception.
-
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
Parameters: - 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:
-
-
sprockets.logging.currentframe()¶ Return the frame object for the caller’s stack frame.
-
sprockets.logging.tornado_log_function(handler)¶ Assigned when creating a
tornado.web.Applicationinstance by passing the method as thelog_functionargument:app = tornado.web.Application([('/', RequestHandler)], log_function=tornado_log_function)