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

Wired in syslog sink into spdlog #105

Open
wants to merge 1 commit into
base: rolling
Choose a base branch
from

Conversation

firesurfer
Copy link

@firesurfer firesurfer commented Oct 10, 2023

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

my_pc my_node[1952055]: [WARN] [1696946734.553229518] [my_node]: my message

It is per default configured to log to the facility: LOG_LOCAL1

By editing /etc/rsyslog.d/50-default.conf and adding the line

We 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

@firesurfer firesurfer changed the title Wired in syslog into spdlog Wired in syslog sink into spdlog Oct 10, 2023
Signed-off-by: Lennart Nachtigall <lennart.nachtigall@sci-mo.de>
@firesurfer
Copy link
Author

@wjwwood and @clalancette sorry for pushing but I would really appreciate some feedback in order to progress :)

@firesurfer
Copy link
Author

@wjwwood and @clalancette sorry to be annyoing but I here am again with a friendly push

Copy link
Collaborator

@fujitatomoya fujitatomoya left a 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.

* \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?

@firesurfer
Copy link
Author

@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 syslog.h. An alternative on windows could be the Windows eventlog.
Furthermore there are syslog client implementations for windows (quick google search which allows to send syslog entries to a syslog server.

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.

@cfveeden
Copy link

cfveeden commented Jan 2, 2024

@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 syslog is a linux only feature of spdlog then adding support for it does not seem to violate any REPs?

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.

@fujitatomoya
Copy link
Collaborator

Does ROS2 need to support the same feature set for linux and windows?

IMO, basically yes but there are some platform dependent code in ROS 2 core.

Can't we have adding other spdlog features like win_eventlog_sink as a separate PR?

i think we can. i think we can have ifdef platform statement to support syslog for linux and eventlog for windows.

@firesurfer
Copy link
Author

@fujitatomoya and @cfveeden

So let me wrap up the results of the discussion so far:

  1. We want to use the configuration file in order to configure such features instead of using environment variables
  2. I ifdef the syslog support to be only included on linux -> In a seperate PR we can add eventlog for windows

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:

Note that the format of this file is backend-specific (and is currently unimplemented for the default backend logger of spdlog)

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 ? I already stated my suggestion above:

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.

If I can find some time for that I will try to wire in the config file support in a separate PR.

@cfveeden
Copy link

@firesurfer. I want to make you aware of a similar discussion going on in #103. Can we perhaps coordinate the various additions under #92?

@firesurfer
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants