Skip to content

Instantly share code, notes, and snippets.

@luminoso
Created January 22, 2020 18:11
Show Gist options
  • Save luminoso/6ceaf04d079018edf59136d2aa365ec3 to your computer and use it in GitHub Desktop.
Save luminoso/6ceaf04d079018edf59136d2aa365ec3 to your computer and use it in GitHub Desktop.
python logging init
import logging
# level=logging._nameToLevel[verbosity_level]
# level=logging.DEBUG
# format="%(asctime)s [%(module)-12.12s] [%(levelname)-5.5s] %(message)s",
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s [%(levelname)-5.5s] %(message)s",
handlers=[
logging.StreamHandler(),
logging.FileHandler(f"./python_run.log"),
])
logging.info(f"Set verbosity to {logging.getLevelName(logging.getLogger().getEffectiveLevel())}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment