python-logging-best-practices

python-logging-best-practices is a skill for Claude Code from terrylica/cc-skills. It costs 34 tokens per session (4,484 once invoked), scanned A, original, MIT.

A guide to logging in Python programs using tools such as Loguru, Structlog, and the standard library. It covers machine-readable logs, file rotation, and choices for local, container, and serverless applications.

In plain words
What is it for?
It is for setting up logs for scripts and services, producing JSON Lines records, rotating log files, and configuring logs in containers or system services.
Why use it?
It helps choose a suitable logging approach and avoid unreliable or hard-to-analyse application output.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions Claude Code.

Part of the devops-tools plugin — 24 skills shipped together , and of cc-skills

not rated 0repo changed 14d ago A scan Socket: passSnyk: passSkillSpector: warn 34 tokens original MIT

Good fit It is for setting up logs for scripts and services, producing JSON Lines records, rotating log files, and configuring logs in containers or system services.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/terrylica/cc-skills/python-logging-best-practices
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add terrylica/cc-skills --skill python-logging-best-practices
Clone the repo
git clone --depth 1 https://github.com/terrylica/cc-skills

Made for: Claude Code.

Or install devops-tools, the plugin that ships this one along with the rest of its 24 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-logging-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/skills/terrylica/cc-skills/python-logging-best-practices/github.svg)](https://agentmods.dev/skills/terrylica/cc-skills/python-logging-best-practices)
Your own site
<a href="https://agentmods.dev/skills/terrylica/cc-skills/python-logging-best-practices"><img src="https://agentmods.dev/badge/skills/terrylica/cc-skills/python-logging-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for python-logging-best-practices

Your own site · 80×15
<a href="https://agentmods.dev/skills/terrylica/cc-skills/python-logging-best-practices"><img src="https://agentmods.dev/badge/skills/terrylica/cc-skills/python-logging-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,484 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 7 May 2026
  • Snyk pass 7 May 2026
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Rogue Agent · line 446
    Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.
    Fix: Prevent the skill from modifying its own code, SKILL.md, or configuration files. Treat skill files as read-only at runtime.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00034 $0.04484
Opus 5.5 $0.00014 $0.01794
Sonnet 5.5 $0.00007 $0.00897
Haiku 4.5 $0.00003 $0.00448

Measured 14d ago against content hash befd847932d9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

python-logging-best-practices scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 14d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- **AI-parseable** (Claude Code can `curl` and analyze directly)
plugins/devops-tools/skills/python-logging-best-practices/SKILL.md · 449 lines

How it starts

The opening of the file, as written. The whole thing — 449 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Logging Best Practices

Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.

When to Use This Skill

Use this skill when:

  • Setting up Python logging for any service or script
  • Configuring structured JSONL logging for analysis
  • Implementing log rotation
  • Choosing between lightweight (zero-dep) and full-featured logging
  • Adding logging to containerized, systemd, or local applications

Overview

Unified reference for Python logging patterns optimized for machine readability (Claude Code analysis) and operational reliability. Starts with the lightest viable approach and scales up only when needed.

Decision Heuristic: Start Light, Scale Up

Is it < 5 services on a single machine, < 1 event/sec?
  YES → Lightweight Pattern (print + JSONL telemetry)
  NO  → Is it containerized / serverless?
    YES → stdout JSON (any library), no file rotation
    NO  → Is OTel tracing required?
      YES → structlog + OTel
      NO  → loguru (CLI tools) or stdlib RotatingFileHandler
Approach Use Case Pros Cons
Lightweight Small systemd services, self-hosted, single operator Zero deps, journald integration, minimal code No severity filtering, no per-module control
loguru CLI tools, scripts, local services Zero-config, built-in rotation, great DX External dep, not truly schema-enforced
structlog Production services, OTel integration ContextVars, processor chains, OTel-native Steeper learning curve
stdlib LaunchAgent daemons, zero-dep constraint No dependencies, Python 3.14 merge_extra More boilerplate, no structured defaults
Logfire AI/LLM observability, Pydantic apps Built on OTel, token/cost tracking, SQL SaaS dependency, newer ecosystem

Read the full file on GitHub · 449 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 14d ago Changed befd847932d9
  2. 1mo ago First seen · 449 lines · 34 tokens per session scan A f7800f7c7b53

Subscribe to this mod's changes

python-logging-best-practices is a skill published in the GitHub repository terrylica/cc-skills (0 stars, last pushed today), licensed MIT. It adds 34 tokens to every session and 4,484 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.

Related

Other skills, from other repositories

agent-django-fastapi-expert

Specialist subagent: Django ORM, Django REST Framework, FastAPI async patterns, and Pydantic v2 specialist. Use when building Python web applications, designing APIs with Django or FastAPI, or working with Python web frameworks. Trigger phrases: Django, FastAPI, DRF, Django REST Framework, Pydantic, ORM, queryset…

travisjneuman/.claude · 92 tokens

ai-ml-development

AI and machine learning development with PyTorch, TensorFlow, and LLM integration. Use when building ML models, training pipelines, fine-tuning LLMs, or implementing AI features.

travisjneuman/.claude · 43 tokens

agent-python-expert

Specialist subagent: Python best practices, type hints, async patterns, and ecosystem expertise. Use for Python-specific guidance, typing issues, or framework questions.

travisjneuman/.claude · 37 tokens

pypi-ops

Publish Python packages to PyPI via OIDC Trusted Publishing (PEP 740 attestations, gh-action-pypi-publish) instead of stored tokens. Use for: invalid-publisher errors, pending-publisher 404s, uv publish/twine, TestPyPI, environment approval gates, and rotating/auditing publish tokens.

0xDarkMatter/claude-mods · 74 tokens

python-async-ops

Python asyncio patterns for concurrent programming. Triggers on: asyncio, async, await, coroutine, gather, semaphore, TaskGroup, event loop, aiohttp, concurrent.

0xDarkMatter/claude-mods · 40 tokens

python-database-ops

SQLAlchemy and database patterns for Python. Triggers on: sqlalchemy, database, orm, migration, alembic, async database, connection pool, repository pattern, unit of work.

0xDarkMatter/claude-mods · 43 tokens