-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add throttled logging when send buffer is full #128
Conversation
d9e2115
to
cf3c3cf
Compare
cf3c3cf
to
930a5a4
Compare
// arguments to pass to the function. | ||
#define FOXGLOVE_DEBOUNCE(f, ms, ...) \ | ||
do { \ | ||
static auto last_call_##__LINE__ = std::chrono::system_clock::now(); \ |
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 don't think __LINE__
is really necessary since the variable is scoped within the do{}while() anyway.
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.
Without __LINE__
, if you use the macro in different places, they would interfere since they would use the same static variable
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.
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.
@achim-k that would be true if this was a function, but it's a macro. Each instance of FOXGLOVE_DEBOUNCE
will copy-paste a new variable definition inside a do { }
block.
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.
Oh, you are right! Will change it
[this](websocketpp::log::level level, const std::string& msg) { | ||
_server.get_elog().write(level, msg); | ||
}, |
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 just [&] { _server.get_elog().write(WARNING, "..."); }
?
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.
That's what I had initially, this gave however errors for melodic:
ISO C++11 requires at least one argument for the ...'' in a variadic macro
Edit: https://github.com/foxglove/ros-foxglove-bridge/actions/runs/3840300446/jobs/6539184886
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 suppose you could just not allow variadic args.
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.
Will remove it
Public-Facing Changes
Description
Logs a warning when a connection's send buffer limit has been reached. To avoid log spam, we log this message at max. every 2.5 seconds.