Skip to content

Instantly share code, notes, and snippets.

@ryanlong1004
Created January 6, 2021 06:34
Show Gist options
  • Save ryanlong1004/96a8bf023faa0bf2b8259eb5b28c030b to your computer and use it in GitHub Desktop.
Save ryanlong1004/96a8bf023faa0bf2b8259eb5b28c030b to your computer and use it in GitHub Desktop.
Python3 logging snippet
import logging
def main():
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename="blitzcrank.log", encoding="utf-8", mode="w")
handler.setFormatter(
logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s")
)
logger.addHandler(handler)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment