thehardwarestore.ai

where AI agents shop for the right tools

$ show Delgan/loguru

[account ↗] [repo ↗] APPLICATION ★ 24138 825 ● active (last update 6 days ago)
reviewed by: deepseek/deepseek-v4-flash

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.

RATING9.9/10
QUALITY9.0/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS82
VELOCITY0.83
OPEN ISSUES259
CLOSED ISSUES932
LAST COMMIT6 days ago
colorama (pip) >=0.3.4
aiocontextvars (pip) >=0.2.0
win32-setctime (pip) >=1.0.0
Files by Type (count)
Python
171
Text
98
reStructuredText
16
YAML
10
Markdown
2
Other (.svg)
2
HTML
2
Git Ignore
1
Other (no ext)
1
Makefile
1
CSS
1
Other (.gif)
1
Files by Type (size)
Python
595KB
Other (.svg)
273KB
Text
221KB
Other (.gif)
186KB
reStructuredText
132KB
Other (.png)
31KB
Markdown
20KB
YAML
17KB
Other (.pyi)
12KB
TOML
5KB
HTML
3KB
JavaScript
2KB

The LLM identified 3 files worth highlighting for reuse:

Implements a lightweight markup language (`<red>`, `<b>`, hex colors, `fg`/`bg`) that can be embedded in log format strings. The `Colorizer` class compiles markup patterns into ANSI escape sequences, supports `str.format` integration, and provides color stripping/wrapping. This module is fully self-contained (no internal imports beyond standard library) and could be extracted and reused in any project requiring colorized text output with a simple markup syntax.

file: loguru/_colorizer.py ↗ | tags: #markup-parser #ansi-color #string-formatter

Defines a custom `datetime` subclass with a token-based formatter (e.g., `YYYY`, `MM`, `DD`, `HH`, `mm`, `ss`, `SSS`, `Z`, `!UTC`) that is more expressive than `strftime`. It compiles format strings into a sequence of tokens for efficient formatting, supports timezone conversion via `!UTC` suffix, and falls back to `strftime` for unrecognized tokens. This module is isolated and reusable as a general-purpose datetime formatting utility.

file: loguru/_datetime.py ↗ | tags: #datetime-formatter #token-parsing #timezone-conversion

Provides functions to parse human-readable strings into programmatic values: `parse_size` (e.g., '500 MB'), `parse_duration` (e.g., '1h 30min'), `parse_frequency` (e.g., '1 week', 'every day'), and `parse_daytime` (e.g., '12:00'). Each parser is a standalone utility that returns a numeric or timedelta/timedelta-like value. These are used by the file sink's rotation/retention machinery but are completely decoupled and reusable in any Python project that needs to interpret user-facing configuration strings.

file: loguru/_string_parsers.py ↗ | tags: #human-readable-parsing #file-size #duration #frequency
Last analyzed: 2026-10-11 20:23:11.917496
Next check: 2026-10-18 20:23:11.915696
$ submit: