Skip to main content

Logging convenience routines.

The logging package is very useful, but a little painful to use. This package provides low impact logging setup and some extremely useful if unconventional context hooks for logging.

The logging verbosity output format has different defaults based on whether an output log file is a tty and whether the environment variable $DEBUG is set, and to what.

Some examples:

Program initialisation:

from cs.logutils import setup_logging

def main(argv):
  cmd = os.path.basename(argv.pop(0))
  setup_logging(cmd)

Basic logging from anywhere:

from cs.logutils import info, warning, error
[...]
def some_function(...):
  [...]
  error("nastiness found! bad value=%r", bad_value)

Context for log messages and exception strings:

from cs.logutils import Pfx
[...]
def func1(foo):
  [...]
  with Pfx("func1(%s)", foo.name):
    [...]
    warning("badness!")   # emits "func1(fooname): badness!"
[...]
def loadfile(filename):
  with Pfx(filename):
    lineno = 0
    for line in open(filename):
      lineno += 1
      with Pfx("%d", lineno):
        [...]
        bah = something from the line ...
        func1(bah)        # emits "filename: lineno: func1(fooname): badness!"
                          # if the warning triggers

This keeps log lines short and provides context in reported errors.

Metadata

Release files for cs-logutils 20150118

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

Source distribution (sdist)

Source distribution for cs-logutils 20150118
File Size Uploaded Provenance Actions
cs.logutils-20150118.tar.gz 8.1 kB Without provenance Details for cs.logutils-20150118.tar.gz

Release files / cs.logutils-20150118.tar.gz

Download URL cs.logutils-20150118.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d0f42906d7704acb41ce21bc85965c08ac41c712a65a68a10f4978e4c70b8e33
BLAKE2b-256 checksum
How to use checksums
d6b79facee2ae6ad32c32d987b5be0bb146980a6dfdfffff0c88b672bfe66afa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for cs-logutils 20150118

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.

Release history Release notifications | RSS feed

This release

20150118 This release

1 release file No provenance

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