Created
July 19, 2024 13:41
-
-
Save aasthavar/c7b9d997a373ab1d48faa080f08da924 to your computer and use it in GitHub Desktop.
setup logging
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 logging | |
| from pytz import timezone | |
| from datetime import datetime | |
| def timetz(*args): | |
| tz = timezone("Asia/Kolkata") | |
| return datetime.now(tz).timetuple() | |
| logging.Formatter.converter = timetz | |
| logging.basicConfig( | |
| format="%(asctime)s %(levelname)s: %(message)s", | |
| level=logging.INFO, | |
| datefmt="%Y-%m-%d %H:%M:%S", | |
| force=True, | |
| ) | |
| logger = logging.getLogger(__name__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment