@@ -99,14 +99,10 @@ following code:
99
99
``` python
100
100
from py_trees_parser import BTParser
101
101
import py_trees
102
- from rclpy import logging
103
-
104
- logger = logging.get_logger(' parser' )
105
- logger.set_level(logging.LoggingSeverity.DEBUG )
106
102
107
103
# Parse the XML file and create the behavior tree:
108
104
xml_file = " behavior_tree.xml"
109
- parser = BTParser(xml_file, logger )
105
+ parser = BTParser(xml_file)
110
106
behavior_tree = parser.parse()
111
107
```
112
108
@@ -222,4 +218,38 @@ and finally in subtree2
222
218
<py_trees .composites.Sequence name =" Cascading Arg Tutorial" >
223
219
<py_trees .behaviors.Success name =" ${baz}" />
224
220
</py_trees .composites.Sequence>
225
- ```
221
+ ```
222
+
223
+ ### Logging
224
+
225
+ By default the parser uses ` rclpy.logging ` module to log messages. However, if this is not available
226
+ it falls back to the python ` logging ` module. The user need not intervene to change the logger as the
227
+ parser will determine which logger to use on its own.
228
+
229
+ #### Logging Level
230
+
231
+ If you would like to set the logging level you will need to know which logger is available. If you are
232
+ using ROS2 then the logger will be ` rclpy.logging ` and the log level can be set in the following way
233
+
234
+ ``` python
235
+ import rclpy
236
+
237
+ from py_trees_parser import BTParser
238
+
239
+ xml_file = " behavior_tree.xml"
240
+ parser = BTParser(xml_file, log_level = rclpy.logging.LoggingSeverity.DEBUG )
241
+ ```
242
+
243
+ On the other hand if you are not using ROS2 then the log level can be set in the following way
244
+
245
+ ``` python
246
+ import logging
247
+
248
+ from py_trees_parser import BTParser
249
+
250
+ xml_file = " behavior_tree.xml"
251
+ parser = BTParser(xml_file, log_level = logging.DEBUG )
252
+ ```
253
+
254
+ - For details on ROS2 log levels see [ here] ( https://docs.ros2.org/foxy/api/rclpy/api/logging.html ) .
255
+ - For details on python log levels see [ here] ( https://docs.python.org/3/library/logging.html#logging-levels )
0 commit comments