Skip to main content

Wrench Code Library

Tests Coverage Python 3.11+ License: MIT


ReadTheDocs


Description

WrenchCL is a comprehensive library designed to facilitate seamless interactions with AWS services, OpenAI models, and various utility tools. This package aims to streamline the development process by providing robust components for database interactions, cloud storage, and AI-powered functionalities.

PyPI Link: WrenchCL on PyPI

Installation

Basic Installation

To install the core package with minimal dependencies:

pip install WrenchCL

Optional Dependencies

WrenchCL uses optional dependencies to keep the core package lightweight while providing additional functionality when needed:

Color Support (Logger)

pip install WrenchCL[color]
# Adds: colorama for beautiful terminal colors

AWS Services

pip install WrenchCL[aws]
# Adds: boto3, psycopg2-binary, sshtunnel, and AWS service type hints
# Enables: RDS connections, S3 operations, Lambda functions, Secrets Manager

Distributed Tracing

pip install WrenchCL[trace]
# Adds: ddtrace for Datadog APM integration
# Enables: Automatic trace correlation in logs

Development Tools

pip install WrenchCL[dev]
# Adds: pytest, coverage, pydantic for development and testing

Complete Installation

pip install WrenchCL[all]
# Installs all optional dependencies for full functionality

Development

To locally develop the plugin, clone the repository locally and make your changes.

Open the console in your working directory; the building command is

python setup.py sdist bdist_wheel

You can then install the package with

pip install ./dist/WrenchCL-0.0.1.dev0-py3-none-any.whl --force-reinstall

Use the --no-dependencies flag to reinstall quickly if there are no dependency changes

pip install ./dist/WrenchCL-0.0.1.dev0-py3-none-any.whl --force-reinstall --no-dependencies

Logger

WrenchCL ships a structured, colorized logger available as a singleton:

from WrenchCL import logger

Output modes

Mode When to use
terminal Local development — colorized, multi-line, syntax-highlighted
json Deployed services — single-line JSON with Datadog triad fields
compact Space-constrained output — single-line, no color
logger.configure(mode="json")          # structured JSON
logger.configure(mode="terminal")      # colored terminal output (default)
logger.configure(deployment_mode=True) # deployed terminal — no color, shows context prefix

Logging methods

logger.debug("message")
logger.info("message")
logger.warning("message")
logger.error("message")
logger.critical("message")
logger.exception("message")   # ERROR level + current exception info

logger.data(obj)               # pretty-print dicts, DataFrames, Pydantic models
logger.header("Section title") # formatted section header

Context prefix

In deployed or verbose mode every log line includes a bracket group that identifies the run, request context, and thread:

[A3X7K | api-handler | Thread-2 | WrenchCL] INFO    [12:34:56|file.py:10] -> message

Scoped prefix — the primary way to attach a prefix. Uses contextvars.ContextVar so it is per-context (thread and async-task safe) and cleans up automatically:

# Context manager — prefix active only inside the block
with logger.prefix("api-handler"):
    logger.info("handling request")   # [run_id | api-handler | WrenchCL]

logger.info("idle")                   # [run_id | WrenchCL]

# Decorator — prefix active for the entire function or method call
@logger.prefix("PaymentService")
def process_payment(order_id):
    logger.info("processing %s", order_id)

Global prefix — process-wide fallback, overridden by any scoped prefix:

logger.set_prefix("worker-1")   # set
logger.set_prefix()             # clear

Thread name — opt-in, off by default:

logger.configure(show_thread_name=True)
# [run_id | prefix | Thread-2 | WrenchCL]

Run ID — a 5-character uppercase alphanumeric ID generated at startup, refreshed with:

logger.initiate_new_run()
print(logger.run_id)   # e.g. "A3X7K"

Datadog integration

Install the trace extra and set LOG_DD_TRACE=true:

pip install WrenchCL[trace]
LOG_DD_TRACE=true python app.py

dd.trace_id and dd.span_id are injected automatically into JSON log records for APM correlation. In AWS Lambda or ECS the logger auto-detects the environment and switches to JSON mode.

Configuration reference

logger.configure(
    mode="terminal",          # "terminal" | "json" | "compact"
    level="INFO",             # "DEBUG" | "INFO" | "WARNING" | "ERROR" | "CRITICAL"
    deployment_mode=False,    # strip color, activate context prefix
    show_thread_name=False,   # include thread name in context bracket
    prefix=None,              # global prefix string
    color_enabled=True,
    highlight_syntax=True,
    trace_enabled=False,      # Datadog APM correlation
)

Temporary overrides:

with logger.temporary(level="DEBUG", mode="compact"):
    logger.debug("verbose output for this block only")

Download files

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

Source Distribution

wrenchcl-6.4.0.tar.gz (159.4 kB view details)

Uploaded Source

Built Distribution

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

wrenchcl-6.4.0-py3-none-any.whl (69.8 kB view details)

Uploaded Python 3

File details

Details for the file wrenchcl-6.4.0.tar.gz.

File metadata

  • Download URL: wrenchcl-6.4.0.tar.gz
  • Upload date:
  • Size: 159.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wrenchcl-6.4.0.tar.gz
Algorithm Hash digest
SHA256 a336fa4cd4c2d2d7ba4f2d5dccecc99ccac8f47591f63150866f2c45f965a29b
MD5 9598c872ce43bd1b13d30cb0f0d5944a
BLAKE2b-256 4ea279c9d9fa222c83b5c575b4981b181cd43eceda7e69be0eb8d8517719b230

See more details on using hashes here.

File details

Details for the file wrenchcl-6.4.0-py3-none-any.whl.

File metadata

  • Download URL: wrenchcl-6.4.0-py3-none-any.whl
  • Upload date:
  • Size: 69.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wrenchcl-6.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bee041ae07d2f71f9c9b51925e804044eb65d716cad975d24b9469753f05ae4
MD5 dd0aab9bad682119fdd93dc5bda25827
BLAKE2b-256 af86dba0b34729cc57b892bd74c7ce287b172c812f3bc37598fdc95c39255c7a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

6.4.0

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