Created
August 21, 2023 08:11
-
-
Save RichardDally/cbe16e8a71d5cbb5b4dee90aa6e1647c to your computer and use it in GitHub Desktop.
Python standard logger bootstrap
This file contains hidden or 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 sys | |
import logging | |
from datetime import datetime | |
logging.basicConfig( | |
level=logging.DEBUG, | |
format="%(asctime)s.%(msecs)03d | %(levelname)s | %(module)s.%(funcName)s | %(message)s", | |
datefmt="%Y/%m/%d %H:%M:%S", | |
handlers=[ | |
logging.FileHandler(datetime.now().strftime('%Y%m%d_%H%M%S.log')), | |
logging.StreamHandler(sys.stdout), | |
] | |
) | |
def main(): | |
logging.info("Hello Python standard logger !") | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment