Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation about setting logger's severity from file #2000

Open
wants to merge 3 commits into
base: rolling
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions source/Tutorials/Logging-and-logger-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,62 @@ Restart the demo including the following command line arguments:

ros2 run logging_demo logging_demo_main --ros-args --log-level logger_usage_demo:=debug

Logger level configuration: configuration file
--------------------------------------------

The severity level for loggers could be set in a configuration file and setting environment variable ``RCUTILS_LOGGING_CONFIG_FILE`` to point to the file path.

.. tabs::

.. group-tab:: Linux

.. code-block:: bash

export RCUTILS_LOGGING_CONFIG_FILE="path_to_config_file"

.. group-tab:: macOS

.. code-block:: bash

export RCUTILS_LOGGING_CONFIG_FILE="path_to_config_file"

.. group-tab:: Windows

.. code-block:: bash

# set "RCUTILS_LOGGING_CONFIG_FILE=path_to_config_file"

The config file has the following structure.

.. code-block:: YAML

# This is a comment
logger1_name=severity # severity could fatal/error/debug/info/warn case-insensitive
logger2.child_logger=debug # Another comment
JafarAbdi marked this conversation as resolved.
Show resolved Hide resolved
# This is a special name used to set the default logger level
default_logger_level=info
Comment on lines +213 to +217
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually yaml format that code-block mentions? probably we would want to use format that rcl_yaml_param_parser can handle otherwise we need to maintain different parser?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this's not a YAML file, I used that one just for highlighting the values


.. note::

The command line severity level prevails the one from the ``RCUTILS_LOGGING_CONFIG_FILE``, for example having the following configuration file

.. code-block:: YAML

default_logger_level=info
logger_usage_demo=error

Running the following command will set the default logger level to ``debug`` not ``info``

.. code-block:: bash

ros2 run logging_demo logging_demo_main --ros-args --log-level debug

Same here logger_usage_demo's level will be ``debug`` rather than ``error``

.. code-block:: bash

ros2 run logging_demo logging_demo_main --ros-args --log-level logger_usage_demo:=debug


Console output formatting
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down