polyswarmclient.log_formatter

Module Contents

class polyswarmclient.log_formatter.ExtraTextFormatter[source]

Bases: logging.Formatter

Custom formatter that adds extra fields to the message string

format(self, record)[source]

Takes a LogRecord and sets record.message = record.msg % record.args This one does some extra work. It searches the record dict for some extra keys we use in the client. (specified as extra= in the logger statement) If it finds one, it grabs the dict and adds an extra %s arg to record.msg, and the dict value to the record.args tuple.

class polyswarmclient.log_formatter.JSONFormatter[source]

Bases: pythonjsonlogger.jsonlogger.JsonFormatter

Class to add custom JSON fields to our logger. Presently just adds a timestamp if one isn’t present and the log level. INFO: https://github.com/madzak/python-json-logger#customizing-fields

add_fields(self, log_record, record, message_dict)[source]