Skip to content

no-loguru-printf-format

Use brace formatting for positional values passed to Loguru.

Why

Loguru formats messages with str.format rather than printf interpolation. A percent-style message with positional values keeps its placeholders and loses the values from the rendered diagnostic.

Fix

Use Loguru brace fields with equivalent formatting, or retain diagnostic values as named structured fields. Review numeric, mapping and width specifications rather than mechanically replacing percent signs.

Examples

Before — flagged Loguru leaves printf placeholders unchanged
app/service.py
from loguru import logger
logger.error("Request %s failed with status %d", "request-marker", 503)
After — preferred Brace fields render positional diagnostic values
app/service.py
from loguru import logger
logger.error("Request {} failed with status {}", "request-marker", 503)