Method: rich.console.Console.log
Calls: 6, Exceptions: 0, Paths: 4Back
Path 1: 3 calls (0.5)
' ' (3)
'\n' (3)
None (3)
None (2) 'right' (1)
None (3)
None (3)
None (3)
False (3)
1 (3)
('foo',) (2) tuple (1)
1def log(
2 self,
3 *objects: Any,
4 sep: str = " ",
5 end: str = "\n",
6 style: Optional[Union[str, Style]] = None,
7 justify: Optional[JustifyMethod] = None,
8 emoji: Optional[bool] = None,
9 markup: Optional[bool] = None,
10 highlight: Optional[bool] = None,
11 log_locals: bool = False,
12 _stack_offset: int = 1,
13 ) -> None:
14 """Log rich content to the terminal.
15
16 Args:
17 objects (positional args): Objects to log to the terminal.
18 sep (str, optional): String to write between print data. Defaults to " ".
19 end (str, optional): String to write at end of print data. Defaults to "\\\\n".
20 style (Union[str, Style], optional): A style to apply to output. Defaults to None.
21 justify (str, optional): One of "left", "right", "center", or "full". Defaults to ``None``.
22 overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None.
23 emoji (Optional[bool], optional): Enable emoji code, or ``None`` to use console default. Defaults to None.
24 markup (Optional[bool], optional): Enable markup, or ``None`` to use console default. Defaults to None.
25 highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Defaults to None.
26 log_locals (bool, optional): Boolean to enable logging of locals where ``log()``
27 was called. Defaults to False.
28 _stack_offset (int, optional): Offset of caller from end of call stack. Defaults to 1.
29 """
30 if not objects:
31 objects = (NewLine(),)
32
33 render_hooks = self._render_hooks[:]
34
35 with self:
36 renderables = self._collect_renderables(
37 objects,
38 sep,
39 end,
40 justify=justify,
41 emoji=emoji,
42 markup=markup,
43 highlight=highlight,
44 )
45 if style is not None:
46 renderables = [Styled(renderable, style) for renderable in renderables]
47
48 filename, line_no, locals = self._caller_frame_info(_stack_offset)
49 link_path = None if filename.startswith("<") else os.path.abspath(filename)
50 path = filename.rpartition(os.sep)[-1]
51 if log_locals:
52 locals_map = {
53 key: value
54 for key, value in locals.items()
55 if not key.startswith("__")
56 }
57 renderables.append(render_scope(locals_map, title="[i]locals"))
58
59 renderables = [
60 self._log_render(
61 self,
62 renderables,
63 log_time=self.get_datetime(),
64 path=path,
65 line_no=line_no,
66 link_path=link_path,
67 )
68 ]
69 for hook in render_hooks:
70 renderables = hook.process_renderables(renderables)
71 new_segments: List[Segment] = []
72 extend = new_segments.extend
73 render = self.render
74 render_options = self.options
75 for renderable in renderables:
76 extend(render(renderable, render_options))
77 buffer_extend = self._buffer.extend
78 for line in Segment.split_and_crop_lines(
79 new_segments, self.width, pad=False
80 ):
81 buffer_extend(line)
Path 2: 1 calls (0.17)
' ' (1)
'\n' (1)
'red' (1)
None (1)
None (1)
None (1)
None (1)
False (1)
1 (1)
('foo',) (1)
1def log(
2 self,
3 *objects: Any,
4 sep: str = " ",
5 end: str = "\n",
6 style: Optional[Union[str, Style]] = None,
7 justify: Optional[JustifyMethod] = None,
8 emoji: Optional[bool] = None,
9 markup: Optional[bool] = None,
10 highlight: Optional[bool] = None,
11 log_locals: bool = False,
12 _stack_offset: int = 1,
13 ) -> None:
14 """Log rich content to the terminal.
15
16 Args:
17 objects (positional args): Objects to log to the terminal.
18 sep (str, optional): String to write between print data. Defaults to " ".
19 end (str, optional): String to write at end of print data. Defaults to "\\\\n".
20 style (Union[str, Style], optional): A style to apply to output. Defaults to None.
21 justify (str, optional): One of "left", "right", "center", or "full". Defaults to ``None``.
22 overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None.
23 emoji (Optional[bool], optional): Enable emoji code, or ``None`` to use console default. Defaults to None.
24 markup (Optional[bool], optional): Enable markup, or ``None`` to use console default. Defaults to None.
25 highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Defaults to None.
26 log_locals (bool, optional): Boolean to enable logging of locals where ``log()``
27 was called. Defaults to False.
28 _stack_offset (int, optional): Offset of caller from end of call stack. Defaults to 1.
29 """
30 if not objects:
31 objects = (NewLine(),)
32
33 render_hooks = self._render_hooks[:]
34
35 with self:
36 renderables = self._collect_renderables(
37 objects,
38 sep,
39 end,
40 justify=justify,
41 emoji=emoji,
42 markup=markup,
43 highlight=highlight,
44 )
45 if style is not None:
46 renderables = [Styled(renderable, style) for renderable in renderables]
47
48 filename, line_no, locals = self._caller_frame_info(_stack_offset)
49 link_path = None if filename.startswith("<") else os.path.abspath(filename)
50 path = filename.rpartition(os.sep)[-1]
51 if log_locals:
52 locals_map = {
53 key: value
54 for key, value in locals.items()
55 if not key.startswith("__")
56 }
57 renderables.append(render_scope(locals_map, title="[i]locals"))
58
59 renderables = [
60 self._log_render(
61 self,
62 renderables,
63 log_time=self.get_datetime(),
64 path=path,
65 line_no=line_no,
66 link_path=link_path,
67 )
68 ]
69 for hook in render_hooks:
70 renderables = hook.process_renderables(renderables)
71 new_segments: List[Segment] = []
72 extend = new_segments.extend
73 render = self.render
74 render_options = self.options
75 for renderable in renderables:
76 extend(render(renderable, render_options))
77 buffer_extend = self._buffer.extend
78 for line in Segment.split_and_crop_lines(
79 new_segments, self.width, pad=False
80 ):
81 buffer_extend(line)
Path 3: 1 calls (0.17)
' ' (1)
'\n' (1)
None (1)
None (1)
None (1)
None (1)
None (1)
False (1)
1 (1)
() (1)
1def log(
2 self,
3 *objects: Any,
4 sep: str = " ",
5 end: str = "\n",
6 style: Optional[Union[str, Style]] = None,
7 justify: Optional[JustifyMethod] = None,
8 emoji: Optional[bool] = None,
9 markup: Optional[bool] = None,
10 highlight: Optional[bool] = None,
11 log_locals: bool = False,
12 _stack_offset: int = 1,
13 ) -> None:
14 """Log rich content to the terminal.
15
16 Args:
17 objects (positional args): Objects to log to the terminal.
18 sep (str, optional): String to write between print data. Defaults to " ".
19 end (str, optional): String to write at end of print data. Defaults to "\\\\n".
20 style (Union[str, Style], optional): A style to apply to output. Defaults to None.
21 justify (str, optional): One of "left", "right", "center", or "full". Defaults to ``None``.
22 overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None.
23 emoji (Optional[bool], optional): Enable emoji code, or ``None`` to use console default. Defaults to None.
24 markup (Optional[bool], optional): Enable markup, or ``None`` to use console default. Defaults to None.
25 highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Defaults to None.
26 log_locals (bool, optional): Boolean to enable logging of locals where ``log()``
27 was called. Defaults to False.
28 _stack_offset (int, optional): Offset of caller from end of call stack. Defaults to 1.
29 """
30 if not objects:
31 objects = (NewLine(),)
32
33 render_hooks = self._render_hooks[:]
34
35 with self:
36 renderables = self._collect_renderables(
37 objects,
38 sep,
39 end,
40 justify=justify,
41 emoji=emoji,
42 markup=markup,
43 highlight=highlight,
44 )
45 if style is not None:
46 renderables = [Styled(renderable, style) for renderable in renderables]
47
48 filename, line_no, locals = self._caller_frame_info(_stack_offset)
49 link_path = None if filename.startswith("<") else os.path.abspath(filename)
50 path = filename.rpartition(os.sep)[-1]
51 if log_locals:
52 locals_map = {
53 key: value
54 for key, value in locals.items()
55 if not key.startswith("__")
56 }
57 renderables.append(render_scope(locals_map, title="[i]locals"))
58
59 renderables = [
60 self._log_render(
61 self,
62 renderables,
63 log_time=self.get_datetime(),
64 path=path,
65 line_no=line_no,
66 link_path=link_path,
67 )
68 ]
69 for hook in render_hooks:
70 renderables = hook.process_renderables(renderables)
71 new_segments: List[Segment] = []
72 extend = new_segments.extend
73 render = self.render
74 render_options = self.options
75 for renderable in renderables:
76 extend(render(renderable, render_options))
77 buffer_extend = self._buffer.extend
78 for line in Segment.split_and_crop_lines(
79 new_segments, self.width, pad=False
80 ):
81 buffer_extend(line)
Path 4: 1 calls (0.17)
' ' (1)
'\n' (1)
None (1)
None (1)
None (1)
None (1)
None (1)
True (1)
1 (1)
tuple (1)
1def log(
2 self,
3 *objects: Any,
4 sep: str = " ",
5 end: str = "\n",
6 style: Optional[Union[str, Style]] = None,
7 justify: Optional[JustifyMethod] = None,
8 emoji: Optional[bool] = None,
9 markup: Optional[bool] = None,
10 highlight: Optional[bool] = None,
11 log_locals: bool = False,
12 _stack_offset: int = 1,
13 ) -> None:
14 """Log rich content to the terminal.
15
16 Args:
17 objects (positional args): Objects to log to the terminal.
18 sep (str, optional): String to write between print data. Defaults to " ".
19 end (str, optional): String to write at end of print data. Defaults to "\\\\n".
20 style (Union[str, Style], optional): A style to apply to output. Defaults to None.
21 justify (str, optional): One of "left", "right", "center", or "full". Defaults to ``None``.
22 overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None.
23 emoji (Optional[bool], optional): Enable emoji code, or ``None`` to use console default. Defaults to None.
24 markup (Optional[bool], optional): Enable markup, or ``None`` to use console default. Defaults to None.
25 highlight (Optional[bool], optional): Enable automatic highlighting, or ``None`` to use console default. Defaults to None.
26 log_locals (bool, optional): Boolean to enable logging of locals where ``log()``
27 was called. Defaults to False.
28 _stack_offset (int, optional): Offset of caller from end of call stack. Defaults to 1.
29 """
30 if not objects:
31 objects = (NewLine(),)
32
33 render_hooks = self._render_hooks[:]
34
35 with self:
36 renderables = self._collect_renderables(
37 objects,
38 sep,
39 end,
40 justify=justify,
41 emoji=emoji,
42 markup=markup,
43 highlight=highlight,
44 )
45 if style is not None:
46 renderables = [Styled(renderable, style) for renderable in renderables]
47
48 filename, line_no, locals = self._caller_frame_info(_stack_offset)
49 link_path = None if filename.startswith("<") else os.path.abspath(filename)
50 path = filename.rpartition(os.sep)[-1]
51 if log_locals:
52 locals_map = {
53 key: value
54 for key, value in locals.items()
55 if not key.startswith("__")
56 }
57 renderables.append(render_scope(locals_map, title="[i]locals"))
58
59 renderables = [
60 self._log_render(
61 self,
62 renderables,
63 log_time=self.get_datetime(),
64 path=path,
65 line_no=line_no,
66 link_path=link_path,
67 )
68 ]
69 for hook in render_hooks:
70 renderables = hook.process_renderables(renderables)
71 new_segments: List[Segment] = []
72 extend = new_segments.extend
73 render = self.render
74 render_options = self.options
75 for renderable in renderables:
76 extend(render(renderable, render_options))
77 buffer_extend = self._buffer.extend
78 for line in Segment.split_and_crop_lines(
79 new_segments, self.width, pad=False
80 ):
81 buffer_extend(line)