Skip to main content

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; old FileHandlers are replaced.
  • No third-party dependencies — stdlib logging only.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dd_logging-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dd_logging-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file dd_logging-0.1.0.tar.gz.

File metadata

  • Download URL: dd_logging-0.1.0.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

Hashes for dd_logging-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b06f37fda123113c273823a5eec61e30e93d0856594bd58d2ef4ff42582b5dab
MD5 6cac2d111ad99b01c865195f3a4dc99e
BLAKE2b-256 5e657d79307da5da3a6ceecfe2f8d43cdaf605755070eda609cd01a8bb45496f

See more details on using hashes here.

File details

Details for the file dd_logging-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dd_logging-0.1.0-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

Hashes for dd_logging-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d06e9275efdebca2a2c99f09d1537a566afc261df3e811654b54d8bef7786198
MD5 cfd619613f08e35417797c32d9c4bc83
BLAKE2b-256 5ef3ae06d52e67e410407d4819d8c77a81610046de3eb5d0478204553805f4cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page