From c0edccbda0e363b114bcbaa0637ea887ad2bb78d Mon Sep 17 00:00:00 2001 From: Alex MacLean Date: Mon, 24 Nov 2025 13:06:52 -0500 Subject: [PATCH 1/2] Add documentation for log format placeholders. Signed-off-by: Alex MacLean --- .../Logging-and-logger-configuration.rst | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/Tutorials/Demos/Logging-and-logger-configuration.rst b/source/Tutorials/Demos/Logging-and-logger-configuration.rst index f90a04af38..241d16059e 100644 --- a/source/Tutorials/Demos/Logging-and-logger-configuration.rst +++ b/source/Tutorials/Demos/Logging-and-logger-configuration.rst @@ -378,6 +378,21 @@ Console output formatting ^^^^^^^^^^^^^^^^^^^^^^^^^ If you would like more or less verbose formatting, you can use the ``RCUTILS_CONSOLE_OUTPUT_FORMAT`` environment variable. +It provides the following options for formatting the log line: + +* ``{severity}`` - ``DEBUG``, ``INFO``, ``WARN``, ``ERROR``, or ``FATAL`` +* ``{severity_with_color}`` - The same as ``{severity}``, but will set the output color of the severity level text. If + ``RCUTILS_COLORIZED_OUTPUT`` is set to 1, ``{severity_with_color}`` is the same as ``{severity}``, because the entire + line is colorized. +* ``{name}`` - The name of the logger. +* ``{message}`` - The log message. +* ``{function_name}`` - The function that contains the log line. +* ``{file_name}`` - The file that contains the log line. +* ``{line_number}`` - The line number of the log line. +* ``{time}`` - The time, in seconds since epoch, of the log line invocation. +* ``{date_time_with_ms}`` - The time, formatted as ``YYYY-MM-DD HH:MM:SS.sss``. +* ``{time_as_nanoseconds}`` - The time, in nanoseconds since epoch. + For example, to additionally get the timestamp and location of the log calls, stop the demo and restart it with the environment variable set: .. tabs:: @@ -451,6 +466,11 @@ You should see that debug, warn, error and fatal logs aren't colorized now. If you start several nodes via ``ros2 launch``, no node has an active terminal attached to it (unless you set ``emulate_tty=True``). This means that to get colorized output for ``ros2 launch``, you need to set ``RCUTILS_COLORIZED_OUTPUT=1`` explicitly. +.. note:: + + Disabling colorizing will disable colorizing the entire line. If you use ``{severity_with_color}`` in the log format, + the severity will still be colorized. + Default stream for console output ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From 1f4231c8765dace8692ae8f78fe3183d6b7b842e Mon Sep 17 00:00:00 2001 From: Alex MacLean Date: Mon, 24 Nov 2025 14:55:50 -0500 Subject: [PATCH 2/2] Fix lint errors by starting each sentence on a new line. Signed-off-by: Alex MacLean --- .../Tutorials/Demos/Logging-and-logger-configuration.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/Tutorials/Demos/Logging-and-logger-configuration.rst b/source/Tutorials/Demos/Logging-and-logger-configuration.rst index 241d16059e..f0db9464a0 100644 --- a/source/Tutorials/Demos/Logging-and-logger-configuration.rst +++ b/source/Tutorials/Demos/Logging-and-logger-configuration.rst @@ -381,8 +381,8 @@ If you would like more or less verbose formatting, you can use the ``RCUTILS_CON It provides the following options for formatting the log line: * ``{severity}`` - ``DEBUG``, ``INFO``, ``WARN``, ``ERROR``, or ``FATAL`` -* ``{severity_with_color}`` - The same as ``{severity}``, but will set the output color of the severity level text. If - ``RCUTILS_COLORIZED_OUTPUT`` is set to 1, ``{severity_with_color}`` is the same as ``{severity}``, because the entire +* ``{severity_with_color}`` - The same as ``{severity}``, but will set the output color of the severity level text. + If ``RCUTILS_COLORIZED_OUTPUT`` is set to 1, ``{severity_with_color}`` is the same as ``{severity}``, because the entire line is colorized. * ``{name}`` - The name of the logger. * ``{message}`` - The log message. @@ -468,8 +468,8 @@ You should see that debug, warn, error and fatal logs aren't colorized now. .. note:: - Disabling colorizing will disable colorizing the entire line. If you use ``{severity_with_color}`` in the log format, - the severity will still be colorized. + Disabling colorizing will disable colorizing the entire line. + If you use ``{severity_with_color}`` in the log format, the severity will still be colorized. Default stream for console output ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^