A systematic approach to application instrumentation, including logging, semantic profiling, and statistics collection.
Project description
lithoxyl
Application instrumentation and logging, with a geological bent. Documentation is available on Read the Docs.
An infomercial of sorts
"Has this ever happened to you?"
Here's an example of some ostensibly well-instrumented code.
import logging
def create_user(name):
logging.info('creating user with name %r', name)
try:
success = _create_user(name)
if success:
logging.info('successfully created user %r', name)
else:
logging.error('failed to create user %r', name)
except Exception:
logging.critical('exception encountered while creating user %r',
name, exc_info=True)
return success
Notice how the logging statements tend to dominate the code, almost drowning out the meaning of the code.
Here's lithoxyl's take:
from lithoxyl import stderr_log
def create_user(name):
with stderr_log.critical('user creation', username=name, reraise=False) as r:
success = _create_user(name)
if not success:
r.failure()
return success
Feature brief
- Transactional logging
- Semantic instrumentation
- Pure Python
- Pythonic context manager API minimizes developer errors
- Decorator syntax is convenient and unobtrusive
- Human-readable structured logs
- Reparseability thanks to autoescaping
- Statistical accumulators for prerolled metrics
- Programmatic configuration with sensible defaults just an import away
- Synchronous mode for simplicity
- Asynchronous operation for performance critical applications
- Log file headers for metadata handling
- Heartbeat for periodic output and checkpointing
- Automatic, fast log parser generation (TBI)
- Sinks
- EWMASink
- DebuggerSink
- MomentSink
- QuantileSink
- StreamSink
- SyslogSink
- and more
Reasons to use Lithoxyl
- More specific: distinguishes between level and status
- Safer: Transactional logging ensures that exceptions are always recorded appropriately
- Lower overhead: Lithoxyl can be used more places in code (e.g., tight loops), as well as more environments, without concern of excess overhead.
- More Pythonic: Python's logging module is a port of log4j, and it shows.
- No global state: Lithoxyl has virtually no internal global state, meaning fewer gotchas overall
- Higher concurrency: less global state and less overhead mean fewer places where contention can occur
- More succinct: Rather than try/except/finally, use a simple with block
- More useful: Lithoxyl represents a balance between logging and profiling
- More composable: Get exactly what you want by recombining new and provided components
- More lightweight: Simplicity, composability, and practicality, make Lithoxyl something one might reach for earlier in the development process. Logging shouldn't be an afterthought, nor should it be a big investment that weighs down development, maintenance, and refactoring.
Development
lithoxyl uses uv for development. To get started:
# Create a virtualenv and install dev dependencies
uv venv && uv pip install -e '.[dev]'
# Run tests
uv run pytest lithoxyl/tests/ -v
# Run tests across Python versions with tox
uvx --with tox-uv tox
Releases are managed with CalVer (YY.MINOR.MICRO) and published
automatically to PyPI via GitHub Actions on tag push. See
.omp/skills/release/SKILL.md for the full release procedure.
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 lithoxyl-26.0.0.tar.gz.
File metadata
- Download URL: lithoxyl-26.0.0.tar.gz
- Upload date:
- Size: 41.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10dad6e379a6c1eec0460720156abc670296c50a85982b26dd0337ffdecc8d3d
|
|
| MD5 |
44db4d29a2bd3faf99c27051085f4d40
|
|
| BLAKE2b-256 |
055e8235af547ae8a7cab45c6f6d491e34cd849f144fe64f3e643b962a666c20
|
Provenance
The following attestation bundles were made for lithoxyl-26.0.0.tar.gz:
Publisher:
publish.yml on mahmoud/lithoxyl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lithoxyl-26.0.0.tar.gz -
Subject digest:
10dad6e379a6c1eec0460720156abc670296c50a85982b26dd0337ffdecc8d3d - Sigstore transparency entry: 1064957948
- Sigstore integration time:
-
Permalink:
mahmoud/lithoxyl@b13135d256817d5453acfe74a62d273eefea8289 -
Branch / Tag:
refs/tags/26.0.0 - Owner: https://github.com/mahmoud
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b13135d256817d5453acfe74a62d273eefea8289 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lithoxyl-26.0.0-py3-none-any.whl.
File metadata
- Download URL: lithoxyl-26.0.0-py3-none-any.whl
- Upload date:
- Size: 48.3 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 |
27ac3a0cf0b56eb680493283afd37ece3ac07fc9db6d831debb62a26011154c6
|
|
| MD5 |
c5b7898be3ab8111c0ac8e45db099769
|
|
| BLAKE2b-256 |
928ee5f2f18313fd664f321e53428c141779bd831ad3848671e95c52f7a90168
|
Provenance
The following attestation bundles were made for lithoxyl-26.0.0-py3-none-any.whl:
Publisher:
publish.yml on mahmoud/lithoxyl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lithoxyl-26.0.0-py3-none-any.whl -
Subject digest:
27ac3a0cf0b56eb680493283afd37ece3ac07fc9db6d831debb62a26011154c6 - Sigstore transparency entry: 1064958003
- Sigstore integration time:
-
Permalink:
mahmoud/lithoxyl@b13135d256817d5453acfe74a62d273eefea8289 -
Branch / Tag:
refs/tags/26.0.0 - Owner: https://github.com/mahmoud
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b13135d256817d5453acfe74a62d273eefea8289 -
Trigger Event:
push
-
Statement type: