How josheppinette/python-logfmter works
Logfmter is a small Python logging formatter that converts standard-library LogRecord data into logfmt text. The application configures it on a logging handler; Python logging invokes it for each record, and the handler emits the returned text. Formatting covers message and extra-field extraction, configured keys/mappings/defaults, value escaping, and exception or stack information. Runtime behavior is concentrated in the sampled formatter module; configuration options and subclassing are documented in the README.
Main entry points: formatter.py Logfmter
Components 9
Other components
- Application
- Python logging
- LogRecord
- Logfmter
src/logfmter/formatter.py - Field extraction
src/logfmter/formatter.py - Configured fields
src/logfmter/formatter.py - Logfmt encoding
src/logfmter/formatter.py - Formatted text
- Logging handler
Connections 12
- Application → Python logging: configures handler
- Application → Logfmter: configures
- Python logging → Logfmter: formats record
- LogRecord → Logfmter: provides data
- Logfmter → Field extraction: extracts fields
- Logfmter → Configured fields: resolves keys
- Logfmter → Logfmt encoding: encodes values
- Field extraction → Logfmt encoding: supplies fields
- Configured fields → Logfmt encoding: supplies fields
- Logfmter → Formatted text: returns text
- Python logging → Logging handler: passes formatted text
- Logging handler → Formatted text: emits