How to use the colorlog.colorlog.ColoredFormatter.__init__ function in colorlog

To help you get started, we’ve selected a few colorlog 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 borntyping / python-colorlog / colorlog / colorlog.py View on Github external
def __init__(self, *args, **kwargs):
        """Overwrite the `reset` argument to False if stream is not a TTY."""
        self.stream = kwargs.pop('stream')

        # Both `reset` and `isatty` must be true to insert reset codes.
        kwargs['reset'] = kwargs.get('reset', True) and self.stream.isatty()

        ColoredFormatter.__init__(self, *args, **kwargs)
github borntyping / python-colorlog / colorlog / colorlog.py View on Github external
Example:

        formatter = colorlog.LevelFormatter(fmt={
            'DEBUG':'%(log_color)s%(msg)s (%(module)s:%(lineno)d)',
            'INFO': '%(log_color)s%(msg)s',
            'WARNING': '%(log_color)sWARN: %(msg)s (%(module)s:%(lineno)d)',
            'ERROR': '%(log_color)sERROR: %(msg)s (%(module)s:%(lineno)d)',
            'CRITICAL': '%(log_color)sCRIT: %(msg)s (%(module)s:%(lineno)d)',
        })
        """
        if sys.version_info > (2, 7):
            super(LevelFormatter, self).__init__(
                fmt=fmt, datefmt=datefmt, style=style, log_colors=log_colors,
                reset=reset, secondary_log_colors=secondary_log_colors)
        else:
            ColoredFormatter.__init__(
                self, fmt=fmt, datefmt=datefmt, style=style,
                log_colors=log_colors, reset=reset,
                secondary_log_colors=secondary_log_colors)
        self.style = style
        self.fmt = fmt