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.2.tar.gz (5.1 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.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dd_logging-0.1.2.tar.gz
  • Upload date:
  • Size: 5.1 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.2.tar.gz
Algorithm Hash digest
SHA256 0fe2ee07c0039c20abe544cc7fb5b05e0aad8ff59c635d2957227d0af564737e
MD5 837fedbde5201c55c7d50b9c86ad6a6e
BLAKE2b-256 66d09344292413b7b4eb4bdc0a32963a4d77cd158c8aa84ae2ebb6d6413950e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dd_logging-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3371f79219f03ff74af67ecdf50bf93092427a9c70c73d582d90abff5ca39be7
MD5 7d40aa39acdccfc0b7465d355fa01d7f
BLAKE2b-256 73352beded0cdf0d16c00db1c29de5d308e540d1adc6b99bf83d234005032a58

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