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.
Works with
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionpython-logging-best-practicesExecute the skills CLI command in your project's root directory to begin installation:
Fetches python-logging-best-practices from terrylica/cc-skills and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate python-logging-best-practices. Access via /python-logging-best-practices in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
28
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
28
stars
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.
Use this skill when:
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.
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.13 merge_extra |
More boilerplate, no structured defaults |
Logfire |
AI/LLM observability, Pydantic apps | Built on OTel, token/cost tracking, SQL | SaaS dependency, newer ecosystem |
For: < 5 systemd services, single server, single operator. Battle-tested in production by ccmax-monitor.
This pattern uses a two-channel architecture:
print(flush=True) → systemd journald (operational logs, human-readable)This maps to the 12-Factor App's "treat logs as event streams" principle. journald handles ops (rotation, filtering, metadata), while the JSONL file serves domain telemetry for post-mortem analysis.
| Concern | Mechanism | Purpose | Lifecycle |
|---|---|---|---|
| Ops logging | print() → journald |
Human debugging, journalctl -u service -f |
Managed by journald (auto-rotated) |
| Telemetry | JSONL file (telemetry.jsonl) |
Structured audit trail, AI/LLM analysis | Append-only, rotated by size |
| State recovery | WAL file (optional) | Crash recovery for irreversible operations | Ephemeral, deleted on success |
"""Append-only JSONL telemetry logger with size-based rotation.
Zero external dependencies. Works with systemd journald for ops logging
and a separate JSONL file for structured machine-readable telemetry.
"""
import json
from datetime import datetime, timezone
from pathlib import Path
TELEMETRY_PATH = Path(__file__).parent / "telemetry.jsonl"
MAX_SIZE = 10 * 1024 * 1024 # 10 MB
BACKUP_COUNT = 3 # Keep 3 rotated backups (~30MB total)
def log_event(event_type: str, data: dict) -> None:
"""Append a structured JSON line to telemetry.jsonl."""
entry = {
"ts": datetime.now(timezone.utc).isoformat(),
"type": event_type,
**data,
}
line = json.dumps(entry, separators=(",", ":")) + "\n"
try:
try:
if TELEMETRY_PATH.stat().st_size > MAX_SIZE:
_rotate()
except FileNotFoundError:
pass
with open(TELEMETRY_PATH, "a") as f:
f.write(line)
except OSError as e:
# Fallback to stderr (captured by journald)
print(f"[telemetry] write failed: {e}", file=__import__("sys").stderr, flush=True)
def _rotate() -> None:
"""Rotate telemetry files: .jsonl → .jsonl.1 → .jsonl.2 → .jsonl.3"""
for i in range(BACKUP_COUNT, 1, -1):
src = TELEMETRY_PATH.with_suffix(f".jsonl.{i - 1}")
dst = TELEMETRY_PATH.with_suffix(f".jsonl.{i}")
if src.exists():
dst.unlink(missing_ok=True)
src.rename(dst)
backup = TELEMETRY_PATH.with_suffix(".jsonl.1")
backup.unlink(missing_ok=True)
TELEMETRY_PATH.rename(backup)
# === Ops logging (goes to journald via stdout) ===
def log(msg: str) -> None:
"""Human-readable operational log line. Captured by journald."""
ts = datetime.now(timezone.utc).strftime("%H:%M:%S")
print(f"[{ts}] {msg}", flush=True)
Usage:
# Operational (human reads via journalctl -u myservice -f)
log("Refreshing token for account X")
log("Switch: account A → account B (reason: 5h breach)")
# Telemetry (machine reads via jq/DuckDB/Claude Code)
log_event("token_refresh", {"account": "X", "expires_in_h": 8.0, "token_fp": "abc12345"})
log_event("account_switch", {"from": "A", "to": "B", "reason": "5h_breach"})
Never pass secrets through the logging pipeline. Log only a non-reversible fragment:
def _token_fingerprint(token: str) -> str:
"""Extract uniquely identifiable chars from a token's mid-section.
The prefix (sk-ant-oat01-) and suffix (...AA) are common across tokens.
Chars 14-22 (after the prefix) are the most unique per-token.
Middle-slice avoids leaking type-prefix metadata that prefix-based
approaches expose.
"""
if len(token) > 25:
return token[14:22]
return token[:8] if token else ""
# Usage: log the fingerprint, never the token
log_event("token_refresh", {"account": name, "token_fp": _token_fingerprint(token)})
Why this is superior to regex redaction filters:
| Approach | Security | Maintenance | Failure mode |
|---|---|---|---|
| Token fingerprinting (log only a slice) | Secret never enters logging pipeline | Zero — works with any token format | Cannot fail — nothing to redact |
| Regex redaction filter | Secret passes through, filtered on output | Must update regexes for new token formats | Silent miss = secret in logs |
This aligns with OWASP Logging Cheat Sheet: "Ensure that no sensitive data is included in log entries." Major platforms (AWS, Stripe, GitHub) use separate non-secret identifiers or partial token display — never full tokens with regex scrubbing.
Regex filters remain useful as a defense-in-depth backstop, not a primary control.
For small deployments, rich JSON health endpoints replace log aggregation:
@app.get("/api/status")
def status():
Implementation Guide
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Steps
- 1Install skill using provided installation command
- 2Test with simple use case relevant to your work
- 3Evaluate output quality and relevance
- 4Iterate on prompts to improve results
- 5Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Related Skills
python-expert-best-practices-code-review
47wispbit-ai/skills
Backend3 shared tagstypescript-best-practices
164jwynia/agent-skills
Backend2 shared tagsnestjs-best-practices
76kadajett/agent-nestjs-skills
Productivity2 shared tagsreact-vite-best-practices
58asyrafhussin/agent-skills
Frontend2 shared tagsnext-best-practices
54vercel-labs/next-skills
Frontend2 shared tagssvelte5-best-practices
32ejirocodes/agent-skills
Frontend2 shared tagsReviews
4.7★★★★★46 reviews- HHana Khanna★★★★★Dec 8, 2024
Useful defaults in python-logging-best-practices — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- PPratham Ware★★★★★Dec 4, 2024
python-logging-best-practices has been reliable in day-to-day use. Documentation quality is above average for community skills.
- AAmelia Srinivasan★★★★★Dec 4, 2024
Registry listing for python-logging-best-practices matched our evaluation — installs cleanly and behaves as described in the markdown.
- YYash Thakker★★★★★Sep 21, 2024
Keeps context tight: python-logging-best-practices is the kind of skill you can hand to a new teammate without a long onboarding doc.
- SSoo Bansal★★★★★Sep 21, 2024
I recommend python-logging-best-practices for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- JJin Khanna★★★★★Sep 21, 2024
Registry listing for python-logging-best-practices matched our evaluation — installs cleanly and behaves as described in the markdown.
- AAarav Reddy★★★★★Sep 5, 2024
python-logging-best-practices fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- DDev Kim★★★★★Aug 24, 2024
python-logging-best-practices is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- DDhruvi Jain★★★★★Aug 12, 2024
Registry listing for python-logging-best-practices matched our evaluation — installs cleanly and behaves as described in the markdown.
- AAisha Farah★★★★★Aug 12, 2024
python-logging-best-practices reduced setup friction for our internal harness; good balance of opinion and flexibility.
showing 1-10 of 46
1 / 5Discussion
Comments — not star reviews- No comments yet — start the thread.