MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / log

Method log

cmd2/rich_utils.py:517–551  ·  view source on GitHub ↗

Override to support ANSI sequences. This method calls [cmd2.rich_utils.prepare_objects_for_rendering][] on the objects being logged. This ensures that strings containing ANSI style sequences are converted to Rich Text objects, so that Rich can correctly calculate the

(
        self,
        *objects: Any,
        sep: str = " ",
        end: str = "\n",
        style: StyleType | None = None,
        justify: JustifyMethod | None = None,
        emoji: bool | None = None,
        markup: bool | None = None,
        highlight: bool | None = None,
        log_locals: bool = False,
        _stack_offset: int = 1,
    )

Source from the content-addressed store, hash-verified

515 )
516
517 def log(
518 self,
519 *objects: Any,
520 sep: str = " ",
521 end: str = "\n",
522 style: StyleType | None = None,
523 justify: JustifyMethod | None = None,
524 emoji: bool | None = None,
525 markup: bool | None = None,
526 highlight: bool | None = None,
527 log_locals: bool = False,
528 _stack_offset: int = 1,
529 ) -> None:
530 """Override to support ANSI sequences.
531
532 This method calls [cmd2.rich_utils.prepare_objects_for_rendering][] on the
533 objects being logged. This ensures that strings containing ANSI style
534 sequences are converted to Rich Text objects, so that Rich can correctly
535 calculate their display width.
536 """
537 prepared_objects = prepare_objects_for_rendering(*objects)
538
539 # Increment _stack_offset because we added this wrapper frame
540 super().log(
541 *prepared_objects,
542 sep=sep,
543 end=end,
544 style=style,
545 justify=justify,
546 emoji=emoji,
547 markup=markup,
548 highlight=highlight,
549 log_locals=log_locals,
550 _stack_offset=_stack_offset + 1,
551 )
552
553
554class Cmd2GeneralConsole(Cmd2BaseConsole):

Callers 1

Calls 1

Tested by 1