Skip to content

Instantly share code, notes, and snippets.

@lyrick17
Created July 16, 2023 08:11
Show Gist options
  • Save lyrick17/9103db10c2e36fda93c7657eb4ee33fc to your computer and use it in GitHub Desktop.
Save lyrick17/9103db10c2e36fda93c7657eb4ee33fc to your computer and use it in GitHub Desktop.

Revisions

  1. lyrick17 created this gist Jul 16, 2023.
    14 changes: 14 additions & 0 deletions logging.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # This is set up code for logging in Python
    # - the format can be changed
    import logging
    logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')

    # this is the set up instead if you want to save the logs in another file
    logging.basicConfig(filename="filename.txt", level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')

    # Disable all the logs...(will be used to stop the logs)
    # - you can change CRITICAL into DEBUG, WARNING, INFO, ERROR, CRITICAL
    # depending on log level you want to disable
    # - where CRITICAL is highest log level
    logging.disable(logging.CRITICAL)
    # Comment this code if you don't want the logs to appear