A simple wrapper around the standard logging library to support structured logging.
Project description
simplestructlogs
A simple wrapper around the python standard logging library that supports structured logs.
JSON logs are supported out of the box, but you can write your own log record classes to support other formats!
Example Usage
from simplestructlogs import StructuredLogger
import logging
def raise_err():
raise Exception("BOOM")
if __name__ == "__main__":
logger = StructuredLogger.get_default_logger("calvin", logging.DEBUG, {"parent-context": "This is cool!"})
logger.debug("debug test")
child_logger = logger.make_child_context_logger("calvin-child", {"child-context": "woo hoo!"})
err = KeyError("uh oh")
child_logger.info("an error", exc_info=err, stack_info=True, extra={"value1": 123, "value2": {"value3" :"456"}})
try:
raise_err()
except Exception as e:
logger.exception("testing exception logging")
logger.warn("test with warning", exc_info=e)
logger.warn("test with warning", is_exception_call=True)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simplestructlogs-0.0.4.tar.gz.
File metadata
- Download URL: simplestructlogs-0.0.4.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2dbb75b157d46028f0da42a0eb97aed488ff96e05f34a2597237982f643537a
|
|
| MD5 |
1fe763afeb619c03eaf2b6dbeaf7d9c3
|
|
| BLAKE2b-256 |
25d9773751cef6c306d6f15a3268bf1005a7004f1e3decf443f915be5862d254
|
File details
Details for the file simplestructlogs-0.0.4-py3-none-any.whl.
File metadata
- Download URL: simplestructlogs-0.0.4-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e27d6638580292975302be220378aaf5e72f2eb0c67db05e26555fb5b82f7d1
|
|
| MD5 |
2bf9ea9368cba55cb86c4b679150cbab
|
|
| BLAKE2b-256 |
36914e864ce834109409a0120fffa3da276b90775026214ab0b58cb9b37f0663
|