loguru

optivent's avatarfrom optivent

Python logging made (stupidly) simple. Focuses on a single, global logger with progressive disclosure to deep source understanding.

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 8, 2026

When & Why to Use This Skill

Loguru is a powerful Python logging library designed to replace the standard logging module with a more intuitive and 'stupidly simple' API. It streamlines the process of recording application behavior by offering a single global logger, automated log rotation, and advanced exception tracking. By utilizing progressive disclosure, it allows developers to move from basic log output to deep source-level understanding, significantly improving observability and reducing boilerplate code in Python projects.

Use Cases

  • Simplifying Python logging setup by replacing complex standard library configurations with a single, easy-to-use global logger.
  • Capturing and recording detailed exception stack traces automatically using the @logger.catch decorator to accelerate debugging and error resolution.
  • Managing production log files efficiently through built-in support for log rotation, compression, and retention policies.
  • Parsing and extracting structured data from log files to facilitate data analysis, monitoring, and system auditing.
  • Enhancing code maintainability by mapping log patterns directly to physical Python source code and AST nodes for deep-dive diagnostics.
nameloguru
descriptionPython logging made (stupidly) simple. Focuses on a single, global logger with progressive disclosure to deep source understanding.
version1.0.0

Loguru: Simplified Python Logging

Loguru replaces the standard logging module with a more powerful, easier-to-use API. This skill provides the "Surface Layer" (Tier 1) for rapid onboarding.

Quick Start

from loguru import logger

# Add a sink (Tier 1: Basic Usage)
logger.add("file.log", rotation="500 MB")

# Log something
logger.info("That is it, beautiful and simple logging!")

Core Patterns

Feature Pattern Description
Sinks logger.add(sys.stderr, format="{time} {level} {message}") Configure where logs go.
Levels logger.debug("Debug msg"), logger.warning("Warn msg") Standard logging levels.
Exceptions @logger.catch Decorator to capture and log exceptions with full stack traces.
Parsing logger.parse(file) Extract structured data from log files.

Progressive Disclosure (The Iceberg)

For deeper understanding, "dive" into the following references: