Skip to content

Instantly share code, notes, and snippets.

@nijave
Last active April 13, 2021 02:31
Show Gist options
  • Save nijave/f2d5d02a4e7d63c979998839057b1c78 to your computer and use it in GitHub Desktop.
Save nijave/f2d5d02a4e7d63c979998839057b1c78 to your computer and use it in GitHub Desktop.
Python logger setup (with alternate format)
import logging
import os
log = logging.getLogger(__file__ if __name__ == "__main__" else __name__)
logging.basicConfig(
level=getattr(logging, os.environ.get("LOG_LEVEL", "INFO").upper()),
format="%(asctime)s [%(levelname)s]: %(message)s",
datefmt="%Y-%m-%dT%H:%M:%S%z",
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment