Skip to content

indented_logger

A logger adapter that adds an indent to the beginning of each message.

CLASS DESCRIPTION
IndentedLoggerAdapter

Logger adapter that adds an indent to the beginning of each message.

FUNCTION DESCRIPTION
get_config

Get the loggic config.

get_indented_logger

Get a logger with indentation.

setup_logging

Configure the logging.

Classes

IndentedLoggerAdapter

IndentedLoggerAdapter(
    logger: Logger,
    extra: Optional[dict] = None,
    depth: int = 2,
    indent_char: str = " ",
    reset: bool = False,
)

Bases: LoggerAdapter

Logger adapter that adds an indent to the beginning of each message.

PARAMETER DESCRIPTION
logger

The logger to adapt.

TYPE: Logger

extra

Extra values to add to the logging context.

TYPE: Optional[dict] DEFAULT: None

depth

The number of indent_char to generate for each indent level.

TYPE: int DEFAULT: 2

indent_char

The character or string to use for indenting.

TYPE: str DEFAULT: ' '

reset

True if the indent level should be reset to zero.

TYPE: bool DEFAULT: False

METHOD DESCRIPTION
dedent

Decrease the indent level by amount.

indent

Increase the indent level by amount.

process

Process the message and add the indent.

reset

Reset the indent level to zero.

ATTRIBUTE DESCRIPTION
current_indent

The current indent level.

TYPE: int

indent_str

The indent string.

TYPE: str

Attributes

current_indent property
current_indent: int

The current indent level.

indent_str property
indent_str: str

The indent string.

Functions

dedent
dedent(amount: int = 1) -> None

Decrease the indent level by amount.

indent
indent(amount: int = 1) -> None

Increase the indent level by amount.

process
process(
    msg: Union[str, RenderableType], kwargs: Optional[MutableMapping[str, Any]]
) -> Tuple[str, MutableMapping[str, Any]]

Process the message and add the indent.

PARAMETER DESCRIPTION
msg

The logging message.

TYPE: Union[str, RenderableType]

kwargs

Keyword arguments passed to the logger.

TYPE: Optional[MutableMapping[str, Any]]

RETURNS DESCRIPTION
Tuple[str, MutableMapping[str, Any]]

A tuple containing the message and keyword arguments.

reset
reset() -> None

Reset the indent level to zero.

Functions

get_config

get_config(verbose: int = 0) -> dict

Get the loggic config.

get_indented_logger

get_indented_logger(name: str) -> IndentedLoggerAdapter

Get a logger with indentation.

setup_logging

setup_logging(verbose: int = 0) -> None

Configure the logging.