Created
November 18, 2022 04:33
-
-
Save sakku116/33893db8299e438aa3e0c5619e481a42 to your computer and use it in GitHub Desktop.
format logging output in python logging
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
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