Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
if extras != '':
extras = self.extras_prefix + extras + self.extras_suffix
record.extras = extras
def remove_extras(self, record):
del record.extras
def format(self, record):
self.add_extras(record)
s = super(ExtrasFormatter, self).format(record)
self.remove_extras(record)
return s
class ColorExtrasFormatter(ColorFormatter, ExtrasFormatter):
"""Combines functionality of ColorFormatter and ExtrasFormatter."""
def format(self, record):
self.add_color(record)
s = ExtrasFormatter.format(self, record)
self.remove_color(record)
return s
TEXT_FORMATTER = ColorExtrasFormatter(fmt=DEFAULT_EXTRAS_FORMAT)
if jsonlogger:
JSON_FORMATTER = jsonlogger.JsonFormatter()
def __init__(self,
keywords=None,
extras_template='[{0}: {1}]',
extras_separator=' ',
extras_prefix=' ',
extras_suffix='',
*args, **kwargs):
self.keywords = set() if keywords is None else keywords
self.extras_template = extras_template
self.extras_separator = extras_separator
self.extras_prefix = extras_prefix
self.extras_suffix = extras_suffix
super(ExtrasFormatter, self).__init__(*args, **kwargs)