Skip to content

proposal for how to unify logging and make it configurable with a file #92

@wjwwood

Description

@wjwwood

To start, after speaking with @clalancette, here's a bullet list of the current state of affairs:

There a few problems with this:

  • rcutils printing to the console means that:
    • we have to configure it separately from the logging backend (including disabling it or changing its default log level)
    • we don't take advantage of implicit features of the logging backend (like the console printing performance of spdlog)
  • filter console messages in rcutils instead of in each output handler means:
    • you cannot have different log levels set for each output handler (or sink), e.g. you cannot have debug go to file and info to console
    • also, you limit what goes over /rosout based on what you output to the console, limiting the remote debugger's ability to see more details than what is printed to the screen (I haven't confirmed this, but it seems to be the case based on the code)

Additionally, the default logging backend that uses spdlog does not have any way to configure it using a file or the command line. There is a command line option to disable it entirely (see: #88 (comment))


The current state makes it impossible to configure the system in a few ways, the most important of which is a use case that came up from one of our clients where they would like to:

  • have a single config file they pass to all nodes (via launch or env var or command line)
  • control the default log level of the file and console separately, e.g. debug to file and info to console
  • control the log level of specific named loggers based on the sink, e.g. logger 'my_node' puts debug to file and info to console

There are other use cases which might be considered, but this one I think is going to be pretty common and is not possible in the current situation.


For these reasons, I propose we make these changes:

  • use spdlog (and generally the logging back ends) for console printing (rather than the implementation in rcutils)
  • delegate the filtering of console messages by log level to each output handler so they can have different levels
  • define a ROS specific console logging config file format that can be parsed and used to configure rcl_logging_spdlog (since spdlog does not have its own config file format)
  • (optional) elevate the concept of "sinks" to the ROS level, so users can configure different log levels per sink for each named logger (at least in the config file if not also from the command line)
    • e.g. something like --log-level my_node:=file:debug,console:info instead of --log-level my_node:=debug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions