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.3.tar.gz (4.4 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.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simplestructlogs-0.0.3.tar.gz
  • Upload date:
  • Size: 4.4 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.3.tar.gz
Algorithm Hash digest
SHA256 6f8aa30acf2130f13bd5e001cdd0c6ad7d4ad3143439a998bf63a717e9bde340
MD5 3faf31b8da6264873420ce40cd29b933
BLAKE2b-256 3940e3cc99a142313d09873adffee413c3f58a0f2f50aca48174566632c175dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simplestructlogs-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 676b8bc1b39724612781c9f73e13b8ee241aa157f6a183c899d2540e9f140a28
MD5 1e44ba8aa1a546be47a96eedeca1d5d1
BLAKE2b-256 2777b4451cd090c1eee095c2bf81455bca497c7a62bd64b6ff4fee677841f382

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