Skip to content

Read the ROSCONSOLE_FORMAT env var to format the logs#174

Open
romainreignier wants to merge 2 commits into
adnanademovic:masterfrom
romainreignier:feature/handle_rosconsole_format_env_var
Open

Read the ROSCONSOLE_FORMAT env var to format the logs#174
romainreignier wants to merge 2 commits into
adnanademovic:masterfrom
romainreignier:feature/handle_rosconsole_format_env_var

Conversation

@romainreignier

Copy link
Copy Markdown
Contributor

This is a naive approach, not much optimized because each call to String::replace() will allocate a new String, a bit like the rospy implementation.

I did not implement the tokens for which the value were not already available. This can be done later.

The new thread-id dependency should not bring too much new dependencies as it only requires libc on Linux for example.

I have added a space to INFO and WARN level strings so all levels have the same string length.
I did this to mimic rosconsole.
But I have just noticed that on the noetic-devel branch, not yet released, the spaces are gone thanks to this PR ros/rosconsole#52
I personally prefer the space so the logs are well aligned.

To implement several loggers, we would need a more advanced logging system. Did you try to use the existing rust log ecosystem and create a rosrust backend for it?

@romainreignier

romainreignier commented Aug 4, 2022

Copy link
Copy Markdown
Contributor Author

Note that I did not add test because I do not know how to capture stdout in the tests.
We would need to use write!() to an object that would be stdout by default but a buffer for the tests.

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.

1 participant