Skip to content

Instantly share code, notes, and snippets.

@davidlares
Created February 2, 2026 00:34
Show Gist options
  • Select an option

  • Save davidlares/c995f550fc18895cef448598360a92e4 to your computer and use it in GitHub Desktop.

Select an option

Save davidlares/c995f550fc18895cef448598360a92e4 to your computer and use it in GitHub Desktop.
Python's logging module example
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