Skip to main content

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

simplestructlogs-0.0.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simplestructlogs-0.0.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file simplestructlogs-0.0.2.tar.gz.

File metadata

  • Download URL: simplestructlogs-0.0.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for simplestructlogs-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d2b72be5263f5d2deaa7320cfbf24a363db7a7f7f10ba7ea095f08b00c1937c2
MD5 8acad99bf5a29580901f2b7aec648d9f
BLAKE2b-256 451dbf7f8a0ae0b1dea7621b956eda27af8f06bf96fa31c80f0cffc6238dec96

See more details on using hashes here.

File details

Details for the file simplestructlogs-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for simplestructlogs-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 80b6d9f1f92a2db1757a3da08f02c49d546f9baf328ec1d65e0aea4e329003ba
MD5 e66728f00575025fd761c9d13924b472
BLAKE2b-256 53d7d69ed6d9958c95ec86936de204f6a7e37f0c6ed20fe6f9a25fece98664f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page