Skip to main content

Simple wrapper over logging for a couple basic features

Project description

logistro (lo-hī-stro)

logistro is an extremely light addition to logging, providing sensible defaults.

It also includes getPipeLogger() which can be passed to Popen() so that its stderr is piped to the already thread-safe logging library.

Which logger level should I use?

debug2 I use if I'm in a situation where it's okay to dump large amounts of information. I'm planning on scrolling.

info I will maybe use at the beginning and end of functions called.

debug Might print stuff from inside functions or it might print shortened versioning of debug2.

Warning, Error, Critical, Exception, these are all more obvious.

Quickstart

import logistro

logger = logistro.getLogger(__name__)

logger.debug2(...) # new!
logger.debug(...) # or debug1()
logger.info(...)
logger.warning(...)
logger.error(...)
logger.critical(...)
logger.exception(...) # always inside except:

# For subprocesses:

pipe, logger = logistro.getPipeLogger(__name__+"-subprocess")
subprocess.Popen(cli_command, stderr=pipe)
os.close(pipe) # eventually

CLI Flags

  • --logistro-level DEBUG|DEBUG2|INFO|WARNING|ERROR|CRITICAL
  • --logistro-human (default)
  • --logistro-structured which outputs JSON

The help for CLI commands can be included in your program:

parser = argparse.ArgumentParser(parents=[logistro.parser])

Functions

  • logistro.set_structured()
  • logistro.set_human()

Generally, they must be called before any other logging call (See note below).

Additionally

logistro.betterConfig(...) applies our formats and levels. It accepts the same arguments as logging.basicConfig(...) except format=, which it ignores. It is better to call this early in a multithread program.

logistro.getLogger(...) will ensure betterConfig().

You can use our two formatters manually instead:

  • human_formatter
  • structured_formatter

Changing Logger Formatter Mid-Execution

With a typical setup, calling set_structured() or set_human() and then logistro.coerce_logger(logistro.getLogger()) will change the format.

See the tech note for an intro into the complexities of logging.

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

logistro-2.0.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

logistro-2.0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file logistro-2.0.1.tar.gz.

File metadata

  • Download URL: logistro-2.0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for logistro-2.0.1.tar.gz
Algorithm Hash digest
SHA256 8446affc82bab2577eb02bfcbcae196ae03129287557287b6a070f70c1985047
MD5 b37d39d1c196ffd57c0b298d27986996
BLAKE2b-256 0890bfd7a6fab22bdfafe48ed3c4831713cb77b4779d18ade5e248d5dbc0ca22

See more details on using hashes here.

Provenance

The following attestation bundles were made for logistro-2.0.1.tar.gz:

Publisher: publish_all.yml on geopozo/logistro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logistro-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: logistro-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for logistro-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 06ffa127b9fb4ac8b1972ae6b2a9d7fde57598bf5939cd708f43ec5bba2d31eb
MD5 2385c6cf180e219aa1f5e65064dd9f11
BLAKE2b-256 54206aa79ba3570bddd1bf7e951c6123f806751e58e8cce736bad77b2cf348d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for logistro-2.0.1-py3-none-any.whl:

Publisher: publish_all.yml on geopozo/logistro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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