logging-guidelines

Replace print statements with structured logging in Python modules.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/sage-base/sagebase --skill logging-guidelines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logging-guidelines
Source: https://github.com/sage-base/sagebase/tree/main/.claude/skills/logging-guidelines
Command: npx skills add https://github.com/sage-base/sagebase --skill logging-guidelines

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Sagebase projects often mix print statements with logging, leading to unstructured, hard-to-maintain output. This Skill standardizes logging practices across the codebase to improve observability and security.

Core Features & Use Cases

  • Enforces logger usage over print statements across modules to ensure consistent log capture.
  • Defines module-level logger initialization and structured log context for better traceability.
  • Guides appropriate log levels and redaction of sensitive data to support debugging and compliance.

Quick Start

Adopt the logging guidelines in a new or existing module. Replace any print statements with logger calls, initialize a module-level logger via logger = logging.getLogger(name), and attach contextual fields using structured logging.

Frequently Asked Questions about logging-guidelines

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace print statements with structured logging in Python?

To enforce consistent logging in Python, initialize a module-level logger using logging.getLogger(__name__) and replace print statements with logger calls. This ensures structured log capture with appropriate levels and contextual fields across modules.

What is structured logging and why use it instead of print statements?

Structured logging standardizes log output by attaching contextual fields to each log entry, replacing unstructured print statements. This improves observability, traceability, and maintainability across a Python codebase by ensuring logs are consistently captured with appropriate levels.

How do I prevent sensitive data leakage in Python log outputs?

To prevent sensitive data leakage in Python logs, apply redaction rules to your structured logging configuration. Ensure your logger prohibits direct prints and sanitizes contextual fields to maintain security and compliance during debugging.

What is the best way to initialize a module-level logger for debugging?

The best way to initialize a module-level logger for debugging is using logger = logging.getLogger(__name__). This ensures structured logs are correctly attributed to their module, providing better traceability and consistent context across the codebase.

Does standardizing Python logging help with refactoring existing modules?

Standardizing Python logging helps with refactoring existing modules by replacing unstructured print statements with configured logger calls. This enforces consistent log levels and structured context, making the codebase easier to maintain and debug.