Skip to content

Instantly share code, notes, and snippets.

@gargolito
Last active May 25, 2019 14:35
Show Gist options
  • Select an option

  • Save gargolito/f1d752dfe8a6c6fa53171d05bd3f109e to your computer and use it in GitHub Desktop.

Select an option

Save gargolito/f1d752dfe8a6c6fa53171d05bd3f109e to your computer and use it in GitHub Desktop.
loguru prevent stdout from core module
import os
import sys
scriptname = os.path.basename(sys.argv[0].split('.')[0])
# configure logging
from loguru import logger as log
log.remove() # supress luguru core stderr output
log_path = '/var/log/'
log.add(log_path + scriptname + "_{time:YYYYMMDD}.log",
format="{time:MMM DD YYYY HH:mm:ss.SSS}-{level}-{function}-{message}",
rotation="1 day", retention="7 days", compression="gz", delay=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment