diff options
Diffstat (limited to 'example.py')
-rwxr-xr-x | example.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/example.py b/example.py new file mode 100755 index 0000000..0892117 --- /dev/null +++ b/example.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +import json +import logging + +import logformat +import requests + + +logfmt_handler = logging.StreamHandler() +logfmt_handler.setFormatter(logformat.LogfmtFormatter()) +logging.basicConfig(handlers=[logfmt_handler], level=logging.DEBUG) + + +logger = logformat.get_logger() + +requests.get('http://example.com') + +logger.debug("what's happening") +logger.info("something's happening") +logger.warning("this seems off", some_id=33) +logger.error("oh no") + +try: + json.loads("maybe") +except: + logger.error("failed to decode", traceback=True) |