log_multiline#

lumopt2.utils.common.log_multiline(target_logger: Logger, level: int, message: str) None#

Log a multi-line message so every line gets the formatter prefix.

Python’s logging.Formatter is invoked once per record and only prepends timestamp / level / logger-name to the first line of the message. Continuation lines therefore render bare on the console and – crucially – can be wider than the terminal, in which case the terminal’s own line wrapping further mangles them (e.g. dropping the leading [ of an array dump and tucking the first value onto the previous record’s line).

This helper splits message on newlines and emits one log record per line, so every line gets its own uniform prefix and long output stays readable regardless of terminal width. An empty string still produces exactly one (empty) record so the call site does not silently drop output.

Parameters:
target_loggerlogging.Logger

Logger to emit on.

levelint

Log level for every emitted record (e.g. logging.INFO).

messagestr

The (possibly multi-line) message to log.