A tiny Loguru wrapper for styled logging
Project description
small-logger
A tiny, opinionated Loguru wrapper that gives your Python apps a consistent, readable log format in two lines of code.
2026-05-11 14:32:01 | INFO | myapp:main:42 | Server started on port 8080
2026-05-11 14:32:01 | ERROR | myapp:handle_request:87 | Connection refused
| Traceback shown below
Installation
uv add small-logger
pip install small-logger
Quick start
from small_logger import init_logger, get_logger
init_logger() # call once at the start of your app
logger = get_logger()
logger.info("Server started")
logger.warning("Disk usage above 80%")
File logging
Pass your app's name to enable automatic file logging:
init_logger(app_name="my-app")
Logs are written to the platform-appropriate directory:
| Platform | Path |
|---|---|
| Windows | %LOCALAPPDATA%\my-app\Logs\app.log |
| macOS | ~/Library/Logs/my-app/app.log |
| Linux | ~/.local/state/my-app/log/app.log |
Files rotate daily at midnight, are kept for 7 days, and are compressed to .zip on rotation.
API
init_logger
init_logger(
level="INFO", # TRACE | DEBUG | INFO | SUCCESS | WARNING | ERROR | CRITICAL
app_name=None, # enables file logging when provided
file=None, # override file logging on/off explicitly
)
| Parameter | Default | Description |
|---|---|---|
level |
"INFO" |
Minimum level to log. |
app_name |
None |
App name for the log file path. When set, file logging is enabled by default. |
file |
None |
Explicitly enable (True) or disable (False) file logging, regardless of app_name. |
Call this once at startup. Subsequent calls are no-ops.
get_logger
logger = get_logger()
logger = get_logger(request_id="abc123", user_id=42)
Returns a Loguru logger bound with optional key-value context. The context is included in every message emitted through that logger instance.
Multiline messages
Continuation lines are automatically indented to align with the first line:
logger.info("Query returned 3 rows:\nrow1\nrow2\nrow3")
2026-05-11 14:32:01 | INFO | myapp:run:10 | Query returned 3 rows:
| row1
| row2
| row3
License
MIT
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 small_logger-0.1.0.tar.gz.
File metadata
- Download URL: small_logger-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22d387ba1c464f7d40977fae4a131ec6d625e56a116a5f8c063ad4e219b48a7a
|
|
| MD5 |
a75d507f7d969007b636a6161d5e8f29
|
|
| BLAKE2b-256 |
be3e77270ce9694e54ae3a171b23fb6e837ff7c4dc5273c1d282790a6a4ca308
|
File details
Details for the file small_logger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: small_logger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e65ba0803e56a9c57c21bb0ca315f72fc530ab05e745a0f2002b2e003c3e62d
|
|
| MD5 |
029722c26c5448abb959ac74f40c4594
|
|
| BLAKE2b-256 |
758ab6ffbee7c6c6f0b139b5c842ed2151bc4ef03df6c62ca5545362b380e6ec
|