-
Notifications
You must be signed in to change notification settings - Fork 36
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
proposal for how to unify logging and make it configurable with a file #92
Comments
If work on this gets started, consider also to allow the use of ROS time instead of system time, so log output is in sync with other time stamps in case of |
Hi @cfveeded pointed me to this discussion coming from #105 @wjwwood Are there any decisions made yet regarding the configuration file for the spdlog backend? As stated in #105: At the moment there is only support for passing in the path to a configuration file. There is no definition in which format the configuration file should be. The documentation actually says:
What kind of format would you prefer ? I would suggest using yaml file as they are widely used all over the ROS2 ecosystem. On the other hand this would mean to introduce a new dependency to yaml-cpp. How should existing parameters be handled ? My guess would be that only adding new parameters to the config file makes sense in order to not break compatibility. As an alternative we could define for currently implemented parameters that the environment variables will always overwrite their counter pendants in the config file. |
The short answer is no, we haven't had time to invest into this. And I know you guys want to add features, new loggers, and address some of the pain points, but I am wary of adding small patches and fixes that we'll have to tick-tock out later in place for a more complete configuration solution. The problem is, I don't know if/when we'll get to it. @clalancette might have a better outlook for that. If we can't do it, others like yourselves certainly can, but I'd really want to see a more complete solution, maybe involving a REP since it will impact other client libraries as well (even ones that don't use To your specific questions...
I think we would really like to change this, so there is a standard for the config file that is not dependent on the backend, but would let you pass through information to the specific backend as needed. Unfortunately, this requires a good deal of design work to consider what is reasonable and not for this file. In terms of what format and dependencies we want, I think YAML is an obvious choice, but not necessarily the only one. We already have a dependency on
They should continue to work more or less as-is, but we can deprecate them as needed. I think they should work in concert with the config file, probably overriding the config file. The classic pattern we use is something like API arguments override env vars which override the config file which overrides the hard coded defaults. But that can sometimes be complicated by circumstances of the particular setting, e.g. some times you want to override the default with an API call or env var, but not block more specific values from other env vars, etc. |
Hi @wjwwood I completely understand the need for a thought through solution. Just adding more and more environment variables can not be the longterm solution. Perhaps we could come up with a solution for how we can still progress with feature development until a solution for the configuration file has been found? |
I also was wondering what time base the logging message was using, I would like the option to include sim time or add both times to the log output. |
This issue has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/improving-ros2-logging-with-spdlog-and-fmt/38817/3 |
The time data is fetched here: https://github.com/ros2/rcutils/blob/rolling/src/logging.c#L1204-L1205 |
Just come across this thread after raising an issue with rcutils and doing some digging (our specific use-case is structured JSON logging with additional fields than those provided by default). The usage of log4cxx in ROS1 seemed very flexible in this regard. At the least, it would be nice to have the option to implement custom spdlog formatters and use a file (akin to the rosconsole config file in ROS1) to specify which formatters to use |
So, I think we can achieve what we want by using a custom The difficulty, I think, will be getting ROS2 to use the custom logger. From what I can tell, the default logger is pretty much hard-coded in terms of formatters and sinks, so I think the only options I can come up with involve writing a wrapper around
Neither of these seem ideal since the first is essentially bypassing ROS's logging framework, and the latter is breaking the layer of abstraction that it provides. I slightly prefer option 2, as it'll avoid us having to also wrap the logging macros to output to additional loggers. Out of curiosity, what is the issue with allowing support for backend-specific configuration files? The Understandably, this doesn't help much in the way of unification, but presumably end users / developers will be aware of the implementation chosen for their system and can supply the relevant config? It feels like it's hard to argue for or against what should / shouldn't be added to a unified logging config, and which fields may be too backend-specific, when there's currently only one implementation as far as I'm aware i.e. |
@rr-tom-noble I haven't looked at it in detail, but I think the following might be relevant: ros2/rcl#1178 and https://discourse.ros.org/t/ros-2-log-system-meets-rsyslog-and-fluentbit/39280 |
To start, after speaking with @clalancette, here's a bullet list of the current state of affairs:
There a few problems with this:
/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:
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:
rcl_logging_spdlog
(since spdlog does not have its own config file format)--log-level my_node:=file:debug,console:info
instead of--log-level my_node:=debug
The text was updated successfully, but these errors were encountered: