How to use the colorlog.escape_codes 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 atlassistant / pytlas / pytlas / cli.py View on Github external
def format(self, record):
    msg = super(CustomFormatter, self).format(record)

    return self._pattern.sub(r'%s\1%s' % (escape_codes['cyan'], escape_codes['reset']), msg) + escape_codes['reset']
github casics / spiral / spiral / logger.py View on Github external
file_handler.setFormatter(file_formatter)
        self._logger.addHandler(file_handler)
        self._outlog   = file_handler.stream

        # Default logging level.
        self._logger.setLevel(logging.INFO)

        # Special handling for Pyro4: turn off its handler b/c we have ours.
        logging.getLogger('Pyro4').addHandler(logging.NullHandler())

        # Console logger.
        if console:
            stream_handler = colorlog.StreamHandler()
            # Don't send color codes inside Emacs shell buffers.
            if os.environ['TERM'] != 'dumb':
                colorlog.escape_codes['lightgreen'] = '\x1b[2m\x1b[32m'
                stream_handler.setFormatter(colorlog.ColoredFormatter(
                    '%(log_color)s%(asctime)s [%(levelname)s] %(message)s',
                    log_colors={
                        'DEBUG'    : 'lightgreen',
                        'INFO'     : 'green',
                        'WARNING'  : 'yellow',
                        'ERROR'    : 'red',
                        'CRITICAL' : 'red,bg_white',
                    },
                    style='%'
                ))
            else:
                stream_handler.setFormatter(colorlog.ColoredFormatter(
                    '%(asctime)s [%(levelname)s] %(message)s',
                ))
            self._logger.addHandler(stream_handler)
github atlassistant / pytlas / pytlas / cli / utils.py View on Github external
def format(self, record):
        msg = super(CustomFormatter, self).format(record)

        return self._pattern.sub(r'%s\1%s' % (escape_codes['cyan'], escape_codes['reset']), msg) \
            + escape_codes['reset']