Shared logging helpers for Digital Duck projects (spl-llm, spl-flow, …)
Project description
dd-logging
Shared logging helpers for Digital Duck projects.
Provides a consistent, timestamped-file logging pattern for CLI tools and Streamlit apps. Used by spl-llm and spl-flow; designed to be reused by any project in the ecosystem.
Install
# from PyPI (once published)
pip install dd-logging
# local editable install (for development)
pip install -e /path/to/dd-logging
Usage
from dd_logging import setup_logging, get_logger, disable_logging
# 1. Call once per process (CLI entry point or app startup)
log_path = setup_logging(
"run",
root_name="my_app", # top-level logger namespace
adapter="openrouter", # appended to filename (optional)
log_level="info", # debug | info | warning | error
)
# → logs/run-openrouter-20260215-143022.log
# 2. In each module
_log = get_logger("nodes.text2spl", root_name="my_app")
_log.info("translating query len=%d", len(query))
# 3. Silence all logging (e.g. --no-log CLI flag)
disable_logging("my_app")
Thin wrapper pattern (recommended)
Each project wraps dd_logging so call-sites never pass root_name:
# myapp/logging_config.py
from pathlib import Path
from dd_logging import setup_logging as _setup, get_logger as _get, disable_logging as _disable
_ROOT = "my_app"
LOG_DIR = Path(__file__).resolve().parent.parent / "logs"
def get_logger(name: str):
return _get(name, _ROOT)
def setup_logging(run_name: str, **kw):
kw.setdefault("log_dir", LOG_DIR)
return _setup(run_name, root_name=_ROOT, **kw)
def disable_logging():
return _disable(_ROOT)
Log file naming
<log_dir>/<run_name>[-<adapter>]-<YYYYMMDD-HHMMSS>.log
logs/run-openrouter-20260215-143022.log
logs/benchmark-claude_cli-20260215-144500.log
logs/generate-20260215-145001.log
Logger hierarchy
my_app ← root (FileHandler attached here)
├── my_app.api ← get_logger("api", "my_app")
├── my_app.nodes.text2spl ← get_logger("nodes.text2spl", "my_app")
└── my_app.flows ← get_logger("flows", "my_app")
All child loggers inherit the root's handler — no per-module handler setup needed.
Design notes
propagate=False— prevents duplicate output when a root Python logger handler is already configured (e.g. Streamlit, pytest, Jupyter).- Stale-handler removal — calling
setup_logging()multiple times in one process (e.g. test suites) is safe; oldFileHandlers are replaced. - No third-party dependencies — stdlib
loggingonly.
Projects using dd-logging
| Project | Root name | Log dir |
|---|---|---|
| spl-llm | spl |
SPL/logs/ |
| spl-flow | spl_flow |
SPL-Flow/logs/ |
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 dd_logging-0.1.1.tar.gz.
File metadata
- Download URL: dd_logging-0.1.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d33fee20f8bb119030d4b15095ea9f656f41a2d6a1b3b55ae3c50b34294dd8d1
|
|
| MD5 |
1927577be1c65ee31ec4e8d068a6424e
|
|
| BLAKE2b-256 |
aea2b54d57323b01f6b9f3d60fd4e61f27eb91f708031ee94bbbec52311b96be
|
File details
Details for the file dd_logging-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dd_logging-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7159413ea68e3159a8e0b62dde9cdec49de7a3ab468387fb21dbae280d1b076
|
|
| MD5 |
419dcad66447f028af2fb7a54a449cd7
|
|
| BLAKE2b-256 |
8b25c72c9de41ec61251ef62ffd697e527a1503805bf353059cac95fa5c0c53b
|