logger¶
The logger package provides otto’s logging infrastructure including custom levels and formatters.
otto’s logger accessor.
'otto' is a plain logging.Logger (no subclass). otto modules emit via
get_otto_logger() / logging.getLogger(__name__); child loggers propagate
to 'otto', where the CLI attaches handlers (see otto.logger.management).
Configuring/replacing handlers is up to the application — otto-the-library only
emits (and otto.logger attaches a NullHandler).
-
otto.logger.logger.get_otto_logger(name: str | None =
None) Logger¶ Return the
'otto'logger (or the'otto.<name>'child).
Register short level-name aliases (WARN, CRIT) with the logging system.
Log formatters: multiline splitter and Rich-markup renderer.
- otto.logger.formatters.format_log_time(dt: datetime) Text¶
Format a datetime as a bracketed
[ YYYY-MM-DD HH:MM:SS.mmm ]Rich Text.
-
class otto.logger.formatters.MultilineFormatter(fmt=
None, datefmt=None, style='%', validate=True, *, defaults=None)¶ Bases:
Formatterlogging.Formatterthat formats each line of a multiline message separately.Prevents leading continuation lines from being emitted without the log prefix (timestamp/level), keeping log files and console output parseable.
- format(record: LogRecord) str¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
-
class otto.logger.formatters.RichFormatter(fmt: str =
'{asctime} [{levelname:^7}] {message}', style: '%' | '{' ='{', **kwargs: Any)¶ Bases:
MultilineFormatterMultilineFormatterfor the log file handler that controls Rich markup.The console handler uses
rich.logging.RichHandlerdirectly; this formatter is attached to the file handler. WhenrichisTrue, markup is rendered to ANSI escape sequences via an internal capture console; whenrichisFalse(the default), ANSI is stripped so log files stay plain.
Per-command / per-host logging disposition.
LogMode decides where a host’s command I/O is recorded — independent of the
log level (INFO vs DEBUG), which stays native to the logger.info/
logger.debug call. See docs/superpowers/specs/2026-06-28-three-sink-logging-design.md.
- class otto.logger.mode.LogMode(value)¶
Bases:
EnumDisposition of a host’s command echo/output across the log sinks.
NORMAL— logged at the call’s level, shown everywhere.QUIET— suppressed from the console +console.log, kept inverbose.log.NEVER— redacted from every sink at every level, including session diagnostics.
LogModegoverns command I/O only;logger.warning/logger.errorand other non-command records are never suppressed by it.-
NORMAL =
'normal'¶
-
QUIET =
'quiet'¶
-
NEVER =
'never'¶