snaplog
Zero-config structured logging for Python. One import, structured JSON output everywhere.
Zero dependencies. Auto-context. Function tracing. JSON by default.
Install
pip install snaplog
Quick Start
from snaplog import get_logger
log = get_logger()
log.info("Order processed", order_id="abc", total=49.99)
# → {"ts":"2026-03-24T21:08:00.123Z","level":"info","msg":"Order processed","order_id":"abc","total":49.99,"logger":"root"}
That's it. No config files. No handlers. No formatters. Just log.
Features
- 🚀 Zero config —
get_logger()and go - 📝 Structured JSON — every log is a JSON object
- 🎯 Auto-context — function name, file, line number captured automatically
- 🔍 Function tracing —
@log.tracedecorator adds timing - 🏷️ Request context —
with log.context(user_id=...)adds fields to all logs - 👁️ Human-readable mode — for development
- 🔌 Stdlib integration — bridges to Python's
loggingmodule - 🧵 Thread-safe — context propagates correctly
- 📦 Zero dependencies — pure Python
API
Basic Logging
from snaplog import get_logger
log = get_logger()
log.debug("Verbose details", step=1)
log.info("Something happened", user_id="u1")
log.warning("Careful!", retries=3)
log.error("Failed to connect", host="db1", error_code=503)
log.critical("System down", component="database")
Auto-Context
# Automatically includes function name, file, and line
def process_order(order_id):
log.info("Processing", order_id=order_id)
# → {..., "func":"process_order", "file":"orders.py", "line":42}
Function Tracing
@log.trace_fn
def fetch_user(user_id):
return db.get(user_id)
# → {"level":"trace","msg":"enter: fetch_user","func":"fetch_user","args":{"user_id":"u1"}}
# → {"level":"trace","msg":"exit: fetch_user","func":"fetch_user","elapsed_ms":12.3,"result":"ok"}
Request Context
with log.context(request_id="r1", user_id="u42"):
log.info("Processing request") # includes request_id + user_id
call_service()
log.info("Done") # still includes them
# Context automatically removed after `with` block
Human-Readable Output
from snaplog import get_logger, HumanFormatter
log = get_logger(formatter=HumanFormatter())
log.info("Hello", name="world")
# → 2026-03-24 21:08:00 [INFO] Hello name=world
Min Level
log = get_logger(min_level="warning") # debug, info suppressed
Stdlib Integration
import logging
from snaplog import SnaplogHandler
handler = SnaplogHandler()
logging.root.addHandler(handler)
logging.info("This goes through snaplog too")
Custom Output
# Write to a file
import sys
log = get_logger(output=open("app.log", "a"))
# Custom output function
def my_output(record_dict):
requests.post("https://logs.example.com", json=record_dict)
log = get_logger(output=my_output)
Output Format
{
"ts": "2026-03-24T21:08:00.123Z",
"level": "info",
"msg": "Order processed",
"logger": "root",
"func": "process_order",
"file": "orders.py",
"line": 42,
"order_id": "abc",
"total": 49.99
}
License
MIT
Metadata
Release files for snaplog 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| snaplog-0.5.0.tar.gz | 12.1 kB | Without provenance | Details for snaplog-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| snaplog-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for snaplog-0.5.0-py3-none-any.whl |
Total release size: 20.5 kB
Release files / snaplog-0.5.0.tar.gz
| Download URL | snaplog-0.5.0.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8772fc2d69d8e0c9df88fc62fa2c03d146db0beed9324b6389f2cb3c47560fa3
|
|
BLAKE2b-256 checksum How to use checksums |
f9061d29a4626aa285c594343293394f8a599cf00743a491cb5c8b9300818b30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|
Release files / snaplog-0.5.0-py3-none-any.whl
| Download URL | snaplog-0.5.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9ba094c71e369fbdbeb7f610f8d97f280a28685d36445921b09300c69fd443a
|
|
BLAKE2b-256 checksum How to use checksums |
bb761aad1c585e4d0e9a92eb4318a06294a6507372cfd2b5dd7d66615d1e4086
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|
Security for snaplog 0.5.0
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.