You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/pages/developers_guide/style_guide.rst
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,3 +76,66 @@ For variables of a class: we do not use the ``Attribute`` section as per the `nu
76
76
x: float
77
77
#: The y coordinate of the point.
78
78
y: float
79
+
80
+
81
+
--------------------------
82
+
Logging and Console Output
83
+
--------------------------
84
+
85
+
Macaron uses the ``rich`` Python library to provide enhanced and well-formatted logging output in the terminal. All logging should be performed using the ``macaron.console`` module.
86
+
87
+
'''''''''''''''''''''''''
88
+
Why use rich for logging?
89
+
'''''''''''''''''''''''''
90
+
91
+
- Provides visually appealing, color-coded, and structured terminal UI.
92
+
- Supports custom components like table, progress bar, and panel for complex output.
93
+
- Makes it easier to spot errors, progress, failed checks, etc.
94
+
95
+
''''''''''''''''''''''''''''''
96
+
How to use the logging handler
97
+
''''''''''''''''''''''''''''''
98
+
99
+
Import the ``access_handler`` from ``macaron.console`` and use it to set/get the custom rich handler. For simple logging, you can use the handler's methods for info, debug, and error messages.
100
+
101
+
.. code-block:: python
102
+
103
+
from macaron.console import access_handler
104
+
105
+
# Get the RichConsoleHandler
106
+
rich_handler = access_handler.get_handler()
107
+
108
+
# Log an info message
109
+
console.info("<info message>")
110
+
111
+
# Log an debug message
112
+
console.debug("<debug message>")
113
+
114
+
# Log an error message
115
+
console.error("<error message>")
116
+
117
+
To modify the console UI, create a function call which takes necessary information and converts them into Rich RenderableType. Also modify the ``make_layout()`` function to use the newly created rich component.
0 commit comments