How to use the daiquiri.formatter.ExtrasFormatter function in daiquiri

To help you get started, we’ve selected a few daiquiri examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jd / daiquiri / daiquiri / formatter.py View on Github external
)
        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()
github jd / daiquiri / daiquiri / formatter.py View on Github external
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)