def setup_logger():
    """Return a logger with a default ColoredFormatter."""
    formatter = ColoredFormatter(
        "%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s",
        datefmt=None,
        reset=True,
        log_colors={
            'DEBUG':    'cyan',
            'INFO':     'green',
            'WARNING':  'yellow',
            'ERROR':    'red',
            'CRITICAL': 'red',
        }
    )

    logger = logging.getLogger('example')
    handler = logging.StreamHandler()
    handler.setFormatter(formatter)
    logger.addHandler(handler)
    logger.setLevel(logging.DEBUG)

    return logger
def setup_logger ( ) : formatter = ColoredFormatter ( "%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s" , datefmt = None , reset = True , log_colors = { 'DEBUG' : 'cyan' , 'INFO' : 'green' , 'WARNING' : 'yellow' , 'ERROR' : 'red' , 'CRITICAL' : 'red' , } ) logger = logging . getLogger ( 'example' ) handler = logging . StreamHandler ( ) handler . setFormatter ( formatter ) logger . addHandler ( handler ) logger . setLevel ( logging . DEBUG ) return logger
Return a logger with a default ColoredFormatter.