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-structuredwhich 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_formatterstructured_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8446affc82bab2577eb02bfcbcae196ae03129287557287b6a070f70c1985047
|
|
| MD5 |
b37d39d1c196ffd57c0b298d27986996
|
|
| BLAKE2b-256 |
0890bfd7a6fab22bdfafe48ed3c4831713cb77b4779d18ade5e248d5dbc0ca22
|
Provenance
The following attestation bundles were made for logistro-2.0.1.tar.gz:
Publisher:
publish_all.yml on geopozo/logistro
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logistro-2.0.1.tar.gz -
Subject digest:
8446affc82bab2577eb02bfcbcae196ae03129287557287b6a070f70c1985047 - Sigstore transparency entry: 660075158
- Sigstore integration time:
-
Permalink:
geopozo/logistro@435074abeb6e38779d7a1798063e415cb82a0bea -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/geopozo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_all.yml@435074abeb6e38779d7a1798063e415cb82a0bea -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06ffa127b9fb4ac8b1972ae6b2a9d7fde57598bf5939cd708f43ec5bba2d31eb
|
|
| MD5 |
2385c6cf180e219aa1f5e65064dd9f11
|
|
| BLAKE2b-256 |
54206aa79ba3570bddd1bf7e951c6123f806751e58e8cce736bad77b2cf348d7
|
Provenance
The following attestation bundles were made for logistro-2.0.1-py3-none-any.whl:
Publisher:
publish_all.yml on geopozo/logistro
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logistro-2.0.1-py3-none-any.whl -
Subject digest:
06ffa127b9fb4ac8b1972ae6b2a9d7fde57598bf5939cd708f43ec5bba2d31eb - Sigstore transparency entry: 660075160
- Sigstore integration time:
-
Permalink:
geopozo/logistro@435074abeb6e38779d7a1798063e415cb82a0bea -
Branch / Tag:
refs/tags/v2.0.1 - Owner: https://github.com/geopozo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_all.yml@435074abeb6e38779d7a1798063e415cb82a0bea -
Trigger Event:
push
-
Statement type: