Last active
May 18, 2021 12:08
-
-
Save a-recknagel/238cd768ccbac31c98d2118834788f06 to your computer and use it in GitHub Desktop.
qlog test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from logging import getLogger, config | |
from colorama import Fore, Back, Style | |
log = getLogger(__name__) | |
config.dictConfig( | |
{ | |
"version": 1, | |
"disable_existing_loggers": False, | |
"formatters": { | |
"qlog": { | |
"()": "qlogging.qlogging.ColoredFormatter", | |
"colors": { | |
'DEBUG': Fore.CYAN + Style.BRIGHT, | |
'INFO': Fore.GREEN + Style.BRIGHT, | |
'WARNING': Fore.YELLOW + Style.BRIGHT, | |
'ERROR': Fore.RED + Style.BRIGHT, | |
'CRITICAL': Fore.RED + Back.WHITE + Style.BRIGHT, | |
}, | |
"format": "%(color)s%(asctime)s [%(levelname)s] %(name)s: %(message)s" | |
}, | |
}, | |
"handlers": { | |
"console": { | |
"level": "DEBUG", | |
"formatter": "qlog", | |
"class": "logging.StreamHandler", | |
"stream": "ext://sys.stdout", | |
}, | |
}, | |
"loggers": { | |
"": { | |
"handlers": ["console"], | |
"level": "DEBUG", | |
"propagate": True, | |
}, | |
}, | |
} | |
) | |
# colored output, since I adapted the format string | |
log.debug("test 1") | |
log.info("test 2") | |
log.warning("test 3") | |
log.error("test 4") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just make sure you update to latest qlogger by:
pip3 install qlogging>=1.0.5