Skip to content

Instantly share code, notes, and snippets.

@yaleman
Created April 1, 2021 22:49
Show Gist options
  • Save yaleman/36ad8a30b971259fc55b272364491a49 to your computer and use it in GitHub Desktop.
Save yaleman/36ad8a30b971259fc55b272364491a49 to your computer and use it in GitHub Desktop.
Logging configurator for loguru
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