Created
February 2, 2026 00:34
-
-
Save davidlares/c995f550fc18895cef448598360a92e4 to your computer and use it in GitHub Desktop.
Python's logging module example
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 | |
| # logging - test apps (debug 10, info 20, warning 30, error 40, critical 50) | |
| # changing Logging configuration for 10 and 20 messages | |
| logging.basicConfig( | |
| level=logging.DEBUG, # = 10 | |
| format='%(filename)s - %(asctime) - %(message)s %(funcName)s - %(levelname)s', | |
| datefmt="%H:%M:%S", | |
| filename='messages.txt', | |
| ) | |
| def messages(): | |
| logging.debug('Debug message') | |
| logging.info('Info message') | |
| logging.warning('Warning message') | |
| logging.error('Error message') | |
| logging.critical('Critical message') | |
| if __name__ == "__main__": | |
| messages() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment