Ushka

API reference

ushka.core.log

Terminal output for Ushka: coloured, compact, standard-library only.

Colours are used only when the stream is a terminal, and never when the NO_COLOR environment variable is set (https://no-color.org). Setting FORCE_COLOR forces them on (useful in CI logs that render ANSI).

def supports_color(stream: IO | None = None) -> bool

True if ANSI colours should be written to stream (stderr by default).

def paint(text: str, *styles: str, enabled: bool | None = None) -> str

Wraps text in ANSI styles (see STYLES) when colour is enabled.

class UshkaFormatter(logging.Formatter)

12:01:02 info message with a coloured level tag.

format(self, record: logging.LogRecord) -> str

def setup_logging(level: LogLevelType = 'INFO') -> logging.Logger

Configures the ushka logger. Safe to call repeatedly.

def get_log_config(level: LogLevelType = 'INFO') -> dict

A logging.config dict that routes Uvicorn's output through Ushka's style.