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).
-
class otto.logger.formatters.MultilineFormatter(fmt=
None, datefmt=None, style='%', validate=True, *, defaults=None)¶ Bases:
Formatter- 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:
MultilineFormatter- 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.
- property rich¶