Created
April 1, 2021 22:49
-
-
Save yaleman/36ad8a30b971259fc55b272364491a49 to your computer and use it in GitHub Desktop.
Logging configurator for loguru
This file contains 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
def setup_logging(logger_object, debug): | |
""" handles logging configuration """ | |
if debug: | |
loguru_format = '<green>{time:YYYY-MM-DD HH:mm:ss}</green> | <level>{level: <8}</level> | <cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>' #pylint: disable=line-too-long | |
logger_object.remove() | |
logger_object.add(sys.stdout, format=loguru_format, level="DEBUG") | |
else: | |
loguru_format = '<level>{message}</level>' | |
logger_object.remove() | |
logger_object.add(sys.stdout, format=loguru_format, level="INFO") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment