rcutils icon indicating copy to clipboard operation
rcutils copied to clipboard

Add option to set logger severity level using a config file

Open JafarAbdi opened this issue 3 years ago • 6 comments

Add ability to specify the logger severity using a config file similar to ROS1's ROSCONSOLE_CONFIG_FILE env-variable, this can be done by export RCUTILS_LOGGING_CONFIG_FILE=path_to_config_file

This's a demo:

https://user-images.githubusercontent.com/16278108/134510231-f88ec412-ae1d-44b0-a832-d48c12cfa3f4.mp4

JafarAbdi avatar Sep 23 '21 12:09 JafarAbdi

* environment variable prevails logging level arguments? I am not sure which one prevails to the other.

@fujitatomoya is there such a facility to set logging levels through environment variables? I don't think so, in which case this question would be moot for now. (correct me if I'm wrong here please)

aprotyas avatar Sep 27 '21 14:09 aprotyas

is there such a facility to set logging levels through environment variables?

No, i do not think so. not via environmental variable, but we can change it with ros arguments. so i just thought that it should be discussed as design before implementation?

fujitatomoya avatar Sep 27 '21 18:09 fujitatomoya

environment variable prevails logging level arguments?

No, logging level arguments prevail the environment variable ones, so if we have logger1 set to debug in the RCUTILS_LOGGING_CONFIG_FILE and we set it to error in the argument (ros2 run pkg node --ros-args --log-level logger1:=error) it will be set to error

it should be able to set default level as well in the configuration file?

Done in the latest commit

probably it would be nice to follow up tutorials how to configure logging level via RCUTILS_LOGGING_CONFIG_FILE?

I'm working on it now

JafarAbdi avatar Oct 06 '21 16:10 JafarAbdi

I'll add tests for this PR later this week

JafarAbdi avatar Oct 06 '21 17:10 JafarAbdi

Please also update the API documentation, describing the new environment variable and the expected file format.

You mean this one, right .?

JafarAbdi avatar Oct 12 '21 14:10 JafarAbdi

@JafarAbdi I mean the docblock for the function being modified:

https://github.com/ros2/rcutils/blob/master/include/rcutils/logging.h#L49-L107

jacobperron avatar Oct 15 '21 17:10 jacobperron