Skip to content

Instantly share code, notes, and snippets.

@sakku116
Created November 18, 2022 04:33
Show Gist options
  • Save sakku116/33893db8299e438aa3e0c5619e481a42 to your computer and use it in GitHub Desktop.
Save sakku116/33893db8299e438aa3e0c5619e481a42 to your computer and use it in GitHub Desktop.
format logging output in python logging
import logging
# set config in main file
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s %(levelname)s\t| %(message)s',
datefmt='%d/%m/%Y %H:%M:%S',
)
# create logger instead using logging directly
# this will load config from main file when it declared from module script
logger = logging.getLogger(__name__)
logger.info("test")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment