ScoloLogger
ScoloLogger is a structured logging layer built on Python's standard logging package. It supports JSON events, task-local context, secret redaction, and timed operations without changing global logging configuration on import.
Installation
pip install ScoloLogger
Configure an application
from scolologger import configure, get_logger
configure(level='INFO', json_output=True)
log = get_logger('checkout')
log.info('payment.accepted', order_id=42, amount=19.90)
JSON output is suitable for Docker, systemd, log collectors, and observability platforms. Use json_output=False for local development.
Context
Context is stored with contextvars, so concurrent asyncio tasks do not overwrite one another.
from scolologger import context, get_logger, new_trace_id
log = get_logger('api')
with context(trace_id=new_trace_id(), user_id=17):
log.info('request.received', method='POST', path='/orders')
log.info('order.created', order_id=42)
A logger can also carry permanent fields:
bot_log = get_logger('scolocrizm').bind(component='telegram')
bot_log.info('request.completed', method='sendMessage', status=200)
Secret redaction
Fields whose names contain token, secret, password, authorization, cookie, or api_key are replaced with [REDACTED]. Telegram bot-token patterns are also removed from strings. Nested dictionaries and lists are processed recursively.
log.info('bot.started', bot_token='123456:secret')
# fields.bot_token is emitted as "[REDACTED]"
Spans
from scolologger import get_logger, span
log = get_logger('worker')
with span(log, 'invoice.sync', invoice_id=42):
synchronize_invoice(42)
The span records invoice.sync.started and either invoice.sync.finished or invoice.sync.failed, including elapsed_ms.
Library authors
Use get_logger() inside a reusable package, but do not call configure(). The application owns levels, handlers, output destinations, and retention.
License
MIT.
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 scolologger-0.1.0.tar.gz.
File metadata
- Download URL: scolologger-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e48040c24c963ecca6d1d61f5bf7df10fb7d71d580da88354f08f65879bb89a
|
|
| MD5 |
a0c457b33c5dc6e81ab96a1d56d24e93
|
|
| BLAKE2b-256 |
b38c196ff5b19ffd3489d44a1af8c440d6ad5286dc81ee93fb88658f3e9e9552
|
File details
Details for the file scolologger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: scolologger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0796d20318d90975b9242d6ad9c5b501873aea371181dcd685dc6723da73935b
|
|
| MD5 |
3c27022489d8ccea40e1b7965a255d89
|
|
| BLAKE2b-256 |
93fa92ed2e013b2cb685a8c4e96457fdb67b870afa0a96142dbd1f6f59cf3036
|