loguru

optivent 的头像作者 optivent

Python日志记录变得(愚蠢地)简单。专注于单一的全局记录器,逐步揭示深入源代码理解。

📖 中文导读:Python日志记录变得(愚蠢地)简单。专注于单一的全局记录器,逐步揭示深入源代码理解。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: loguru description: Python logging made (stupidly) simple. Focuses on a single, global logger with progressive disclosure to deep source understanding. version: 1.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: