-
Notifications
You must be signed in to change notification settings - Fork 35
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
Wired in syslog sink into spdlog #105
base: rolling
Are you sure you want to change the base?
Conversation
Signed-off-by: Lennart Nachtigall <lennart.nachtigall@sci-mo.de>
@wjwwood and @clalancette sorry for pushing but I would really appreciate some feedback in order to progress :) |
@wjwwood and @clalancette sorry to be annyoing but I here am again with a friendly push |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@firesurfer sorry to be late to get back to you. i got a couple of comments.
CC: @clalancette @wjwwood
- does this work on Windows? (I do not think it does...) Windows is one of the Tier 1 platform, and spdlog backend should be working for all of them.
- i think having environmental variable for each configuration or setting is not really good idea. for that, we already have
const char * config_file
argument for backend logger initialization. i think that would be the place to put those settings and configuration.
rcl_logging/rcl_logging_interface/include/rcl_logging_interface/rcl_logging_interface.h
Lines 36 to 39 in 1af4e49
* \param[in] config_file The location of a config file that the external | |
* logging library should use to configure itself. | |
* If provided, it must be a null terminated C string. | |
* If set to NULL or the empty string, the logging library will use defaults. |
btw, config_file
is not used currently, so maybe we could start, what configuration or setting should be described in config_file
for rcl_logging_spdlog
?
@fujitatomoya Thanks a lot for your answer. In deed spdlog does not support syslog on Windows. I just took a look at the implementation and it directly uses Regarding the config file: 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. |
@fujitatomoya Does ROS2 need to support the same feature set for linux and windows? REP2000 does not seem to say much about that. So if Can't we have adding other spdlog features like win_eventlog_sink as a separate PR? Of course, checking the OS and reporting configuration errors would be required to assist users in configuring their systems properly in this case. |
IMO, basically yes but there are some platform dependent code in ROS 2 core.
i think we can. i think we can have |
So let me wrap up the results of the discussion so far:
Regarding the configuration file: 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 How should existing parameters be handled ? I already stated my suggestion above:
If I can find some time for that I will try to wire in the config file support in a separate PR. |
@firesurfer. I want to make you aware of a similar discussion going on in #103. Can we perhaps coordinate the various additions under #92? |
@cfveeden If I understand the discussion in #92 correctly it is unclear when a common solution for the log configuration will be found / worked on. Does this mean no addition to the rcl_logging system can be made until at some point in the future this solution has been found? (Sorry for being a bit provocative there) The reason I am pushing towards having a syslog functionality is that it is hard at the moment to really get a complete log of an application (without starting to manually collect multiple logfiles from multiple PCs) which can be necessary for debugging certain issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the motive, thanks for putting this together. Added a few potentially simple coding questions.
For Windows, there was a recent change announced discourse.ros.org#39502 but I'm not sure how/if that affects this sort of code change.
One question: Like I described one example of logging pipeline answers.ros.org#371667 (of ros1, but I hope the flow of pipeline is the same in ros2), there's a way to configure in OS-system level outside of ROS, in order for logs to be flushed to syslog
. In my experience in product dev that sort of flexibility was important.
With this change, if ROS is configured to log onto syslog
, would that affect system level configuration for logging? E.g. If my ROS2 application is running as systemd
service AND ROS is configured to log to syslog, would I see logs duplicated in syslog
?
// explicitly false | ||
return false; | ||
} | ||
if ("1" == env_var_value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ("1" == env_var_value) { | |
else if ("1" == env_var_value) { |
This if
clause and the one previous if
are both checking env_var_value
, so unless there's a reason for us to check "0" and "1" separately, why don't we combine as a single if-elseif
?
try { | ||
std::string env_var_value = rcpputils::get_env_var(env_var_name); | ||
|
||
if (env_var_value.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not convert this if
clause as else
?
@@ -186,6 +236,9 @@ rcl_logging_ret_t rcl_logging_external_initialize( | |||
// the old behavior is to not configure the sink at all, so do nothing | |||
} | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these 3 empty lines addition necessary?
The discussion points in this thread are still valid. In some way either it should produce an error on windows or fallback to the windows eventlog
I can give you a clear yes and no answer. It depends on the configuration of your local syslog daemon. Regarding the code suggestions -> I think it does not make sense to discuss any of the code until #92 came to a conclusion. |
This PR wires in an additional syslog sink into the spdlog implementation.
The syslog can be enable via the environment variable:
RCL_LOGGING_SPDLOG_ENABLE_SYSLOG=1
Example output in
/var/log/syslog
It is per default configured to log to the facility:
LOG_LOCAL1
By editing
/etc/rsyslog.d/50-default.conf
and adding the lineWe can write the specific log into a seperate file. Alternatively it is possible to redirect the log to a remote server which is useful in enterprise environments.
local1.* -/var/log/local1.log
Additional information
For more background information see the related PR in:
ros2/launch#737