Skip to content

Instantly share code, notes, and snippets.

@memark
Last active September 27, 2020 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save memark/093904bce7f3d385c347d9788aa01215 to your computer and use it in GitHub Desktop.
Save memark/093904bce7f3d385c347d9788aa01215 to your computer and use it in GitHub Desktop.
iso format timestamp python
import logging
logger = logging.getLogger()
ch = logging.StreamHandler()
formatter = logging.Formatter(fmt='%(asctime)s.%(msecs)03dZ - %(msg)s', datefmt='%Y-%m-%dT%H:%M:%S')
ch.setFormatter(formatter)
logger.addHandler(ch)
logger.warning("some message")
# --> 2020-09-27T20:29:35.841Z - debug message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment