Skip to main content

linux test status

scopedlog

A library for scoped logging on top of structlog (or similar sinks), inspired by the idea of an apparently defunct lithoxyl. Note that I (kshpytsya) have deliberatly not looked into actual lithoxyl's implementation to keep a fresh mind.

Here is an example:

import contextlib                                                                                                                         import structlog
import structlog.stdlib
import structlog.dev
import structlog.processors
import scopedlog
import scopedlog.sink_structlog
import scopedlog.idgen_seq

structlog.configure(processors=[
    structlog.stdlib.add_log_level,
    structlog.processors.ExceptionPrettyPrinter(),
    structlog.dev.ConsoleRenderer()
])

slog = scopedlog.ScopedLog(
    sink=scopedlog.sink_structlog.StructlogSink(structlog.get_logger()),
    id_gen=scopedlog.idgen_seq.GlobalSeqScopeIdGenenerator()
)

with contextlib.suppress(RuntimeError):
    with slog.info("scope1", k1=1) as sl:
        sl.debug("state1", k2=2, k3=3)
        sl.info("state1", k4=4)
        sl.warn("state1", k5=5)
        raise RuntimeError("bad one")

with contextlib.suppress(RuntimeError):
    with slog.debug("scope2", k1=1) as sl:
        sl.debug("state1", k2=2, k3=3)
        sl.info("state1", k4=4)
        sl.warn("state1", k5=5)
        raise RuntimeError("bad too ;)")

with slog.debug("scope3") as sl:
    sl.fail()

with slog.debug("scope4") as sl:
    sl.exit_kw["k1"] = 1

And expected output:

See tests for more examples.

Metadata

Release files for scopedlog 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scopedlog 0.1.4
File Size Uploaded Provenance
scopedlog-0.1.4.tar.gz 7.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for scopedlog 0.1.4
File Interpreter ABI Platform
scopedlog-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / scopedlog-0.1.4.tar.gz

Download URL scopedlog-0.1.4.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d32b7c7f572733992d9c3f10a490c45d68d28fc931c8f43c930ad68c23156162
BLAKE2b-256 checksum
How to use checksums
45df742b6f9554b8b8f56912146c76829a9f2b88bd5daa79dc48c9218e21829a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scopedlog-0.1.4-py3-none-any.whl

Download URL scopedlog-0.1.4-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec0dca83281301af19f2e473a8e883784a027f3d8f541bbd2d3b1b99d8845562
BLAKE2b-256 checksum
How to use checksums
856c1407050769a205f34828c4115410fa53b9b15971cefa9914715f27837aa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for scopedlog 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page