Skip to content

Log

log

Centralised logging configuration shared by the server, launcher CLI, GUI, and Modal jobs

One Setup
  • setup_logging configures the mirumoji logger with a rotating file handler and / or a Rich console handler

  • The file format is clean and structured for later reading, while the console renders through Rich

  • The console handler coordinates with tqdm so the live progress bars rendered by file transfers / transcription are never broken by a log line

MIRUMOJI_LOGGING_THEME = Theme({'accent': '#E2533B', 'accent.soft': '#F08A6E', 'info': '#5E83A4', 'success': '#8AA06A', 'danger': 'bold #C8503D', 'warning': '#D9A441', 'muted': '#7E7567', 'heading': 'bold #F4EEE3', 'ink': '#F4EEE3', 'highlighter.ok': '#8AA06A', 'highlighter.bad': 'bold #C8503D', 'highlighter.warn': '#D9A441', 'highlighter.number': '#C99A57', 'highlighter.uuid': '#F08A6E', 'highlighter.path': '#5E83A4', 'highlighter.url': 'underline #5E83A4', 'highlighter.module': '#7E7567'}) module-attribute

Defines the Rich theme for mirumoji's console logging messages mimicking the frontend's Sumi & Shu design

MirumojiHighlighter

Bases: RegexHighlighter

Custom Rich highlighter for mirumoji's console logging messages

setup_logging(*, log_file='backend.log', console=True, level=None, capture_root=False)

Configures the mirumoji logger with shared handlers and formatters

Handlers
  • A RotatingFileHandler (5 MB x 3 backups) under HOST_LOG_PATH, using a clean structured format, when log_file is given

  • A tqdm-aware Rich console handler when console is True

Idempotent

On each call, only the handlers attached by this module are cleared so that repeated calls never stack handlers or disturb third-party ones

Parameters:

Name Type Description Default
log_file str | None

Log file name under HOST_LOG_PATH, or None for no file handler (Modal containers only emit to stdout)

'backend.log'
console bool

Whether to attach the Rich console handler

True
level str | int | None

Explicit level, or None to read MIRUMOJI_LOGGING_LEVEL (default INFO)

None
capture_root bool

When True, also attach the same file handler to the root logger so third-party records get a UTF-8 sink instead of logging's last-resort stderr handler. Requires log_file

False

Raises:

Type Description
ValueError

If capture_root is set without a log_file