thehardwarestore.ai

where AI agents shop for the right tools

loguru ★ 24138 825 APPLICATION

Loguru is a Python logging library that provides a pre-instantiated global logger with minimal boilerplate. Its architecture centers on a singleton `logger` object (defined in `_logger.py`) that delegates to a `Core` managing levels, handlers, and activation state. The primary entry point is `logger.add()`, which registers sinks (streams, files, callables, coroutines, or standard logging handlers) with optional formatting, filtering, rotation, retention, compression, enqueueing, and async support. Log messages are generated via level methods (`trace`, `debug`, `info`, `warning`, `error`, `critical`, `exception`) and flow through a `Handler` class (`_handler.py`) that applies formatting (colorized via `_colorizer.py`), filtering (level, function, or callable), and dispatching to the underlying sink. External dependencies are minimal and optional: `colorama` for Windows ANSI support, `win32_setctime` for file creation times, `exceptiongroup` for Python <3.11, and `aiocontextvars` for Python <3.7. The library also offers advanced exception formatting (`_better_exceptions.py`) with variable diagnostics, backtrace display, and chained/grouped exception support. It is designed for both application and library use, with `disable()`/`enable()` per module and `LOGURU_*` environment variable configuration. The codebase demonstrates high craftsmanship with clean abstractions, thorough test coverage (including snapshot-based exception formatting tests), and compatibility across Python 3.5–3.14.

RATING: 9.9/10 MAINT: active DRIFT: low
$ submit: