Skip to content

Change log level for lifecycle_publisher#1715

Merged
wjwwood merged 5 commits intoros2:masterfrom
alsora:patch-1
Aug 19, 2021
Merged

Change log level for lifecycle_publisher#1715
wjwwood merged 5 commits intoros2:masterfrom
alsora:patch-1

Conversation

@alsora
Copy link
Copy Markdown
Collaborator

@alsora alsora commented Jul 15, 2021

De-activating a lifecycle publisher while the function that was invoking publish is still running floods the log of useless warning messages.
This requires to add a boolean check around the publish call, thus making useless the choice of a lifecycle publisher over a regular publisher.

De-activating a lifecycle publisher while the function that was invoking `publish` is still running floods the log of useless warning messages.
This requires to add a boolean check around the publish call, thus making useless the choice of a lifecycle publisher

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Jul 15, 2021

I think having a visible warning might still be worth having, @Karsten1987 what do you think?

We have logging macros like "throttled", "once", and even ones that have arbitrary predicates, e.g.:

https://docs.ros2.org/foxy/api/rclcpp/logging_8hpp.html#a451bee77c253ec72f4984bb577ff818a

Maybe we could warn throttled, and debug every time? (or something like that)

@alsora
Copy link
Copy Markdown
Collaborator Author

alsora commented Jul 15, 2021

Nice, I didn't know about those macros.
Ideally I would like a warn log only once but controlled by a flag that gets reset after a transition to the active state.
We can then also have debug logs all the time

@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Jul 15, 2021

Either way works for me, you can have your own flag to control when using this macro and a custom function or expression.

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
Copy link
Copy Markdown
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.

I am not really inclined to have this dedicated flag to control print or not to break the API. @alsora do you have particular reason to use RCLCPP_WARN_FUNCTION?

how about,

  • RCLCPP_DEBUG, then user can control the logging.
  • RCLCPP_WARN_ONCE only once state is deactivated, then reset that once it becomes activated internally w/o changing API?

@alsora
Copy link
Copy Markdown
Collaborator Author

alsora commented Aug 2, 2021

@fujitatomoya why is this breaking the API?
My first implementation was using RCLCPP_DEBUG, I then changed it after the other review comments.

@fujitatomoya
Copy link
Copy Markdown
Collaborator

@alsora sorry my bad, i though new parameter for the method, but just a constructor.

My first implementation was using RCLCPP_DEBUG

okay, i am good with this one too.

Copy link
Copy Markdown
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Just a note, this won't be backport-able since it will break ABI.

@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Aug 4, 2021

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Aug 5, 2021

Looks like it doesn't compile.

@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Aug 5, 2021

Looks like it tries to *function and that doesn't work for lambda... Not sure what the right thing to do there is.

@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Aug 5, 2021

We can't coerce a lambda that captures into a function pointer... Unfortunately. So I'm not actually sure how to fix this...

I think we need a new kind of macro that takes a function and a void * state argument. We could wrap that up so lambdas with captures work in the rclcpp macro, but at the bottom I think we need a new macro in rcutils that takes a function and a state to be passed to that function each time it is called.

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
@alsora
Copy link
Copy Markdown
Collaborator Author

alsora commented Aug 10, 2021

My bad, I only built the code without unit tests, but this file is just a header so it didn't actually got built.
I went back to use RCLCPP_WARN and added an helper function that manages the logging logic

@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Aug 11, 2021

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Aug 11, 2021

The cmake warning is probably due to this needing to be rebased. I'll wait for feedback on doc changes, and if you can rebase it at the same time I'd appreciate that.

Alberto Soragna and others added 2 commits August 13, 2021 16:46
@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Aug 19, 2021

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@wjwwood wjwwood merged commit 4fcd05d into ros2:master Aug 19, 2021
@alsora alsora deleted the patch-1 branch August 19, 2021 21:29
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.

3 participants