patera.logging¶
See the logging guide.
Logging module
DefaultLoggerConfig
¶
Bases: LoggerConfigBase
Configuration of Patera's default console logger (DEFAULT_LOGGER).
Unknown keys are rejected, so a misspelt setting fails at startup.
LogFilesConfig
¶
Bases: BaseModel
Configuration of the application's JSON Lines log files (LOG_FILES).
JsonLogFiles
¶
JsonLogFiles(config: LogFilesConfig, root_path: Union[str, Path], default_logger_name: str = 'Patera Logger')
Writes log records to rotating JSON Lines files and reads them back.
The active file is PATH. Rotated files sit next to it and carry the
rotation time in their name, for example patera.2026-10-09_13-25-00_123456.jsonl.
attach
¶
Adds the file sink to Loguru. Returns the handler id, or None if disabled.
read
¶
Returns the newest records, oldest first. At most limit records are
returned; the default is READ_LIMIT. Lines that are not complete
JSON objects, such as a line still being written, are skipped.
read_async
async
¶
Same as read(), but runs the file access in a worker thread.
LoggerBase
¶
Bases: ABC, Generic[AppT]
Base template for configuring a Loguru sink.
Settings are read from the configuration field named after the class in upper snake case (AuditLogger -> AUDIT_LOGGER). Subclasses override get_sink() or the other getters to change how the sink is set up.
LoggerConfig
¶
LogLevel
¶
Bases: StrEnum