Skip to content

feat(tools): add standardized aden_tools logging #1477

@Jonathan1366

Description

@Jonathan1366

Summary

aden_tools currently does not have a shared logging standard. Errors are correctly returned to callers, but maintainers don’t have consistent runtime logs to help with debugging and operational visibility—especially important for MCP STDIO, where stdout must remain clean for JSON-RPC.

We also ran into a practical issue during development: Python logging can raise a runtime KeyError when extra contains reserved LogRecord keys (for example extra={"name": ...}), which can unexpectedly crash otherwise normal error paths.


Proposal

  • Add a small, centralized logging helper:

    • configure_logging() (safe to call multiple times)
    • get_logger()
  • Default all logs to stderr (STDIO / JSON-RPC safe).

  • Allow basic configuration via environment variables:

    • ADEN_TOOLS_LOG_LEVEL (default: INFO)
    • ADEN_TOOLS_LOG_FORMAT
  • Standardize safe structured log metadata:

    • Avoid reserved LogRecord fields such as name, message, and asctime.
  • Add a lightweight test to ensure:

    • Logging initialization is idempotent (no duplicate handlers).

Example (real issue → safe pattern)

Before

logger.warning(
    "pdf_read file not found",
    extra={"name": path.name}
)

This can raise a runtime KeyError due to LogRecord field collisions.

After

logger.warning(
    "pdf_read file not found",
    extra={"file_name": path.name}
)

Uses a neutral metadata key and avoids collisions.


Test plan

cd tools
python3 -m pip install -e ".[dev]"
python3 -m pytest tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions