Add throttle option for logging #166
Add throttle option for logging #166HannesBachter wants to merge 14 commits intoteam-vigir:developfrom
Conversation
| if not log_id in Logger._last_logged.keys() or \ | ||
| rospy.Time.now().to_sec() - Logger._last_logged[log_id].to_sec() > period: | ||
| Logger.log(text, severity) | ||
| Logger._last_logged.update({log_id: rospy.Time.now()}) |
There was a problem hiding this comment.
Thanks for adding! Would you see a way that entries can also be removed again eventually so that this dict can't grow infinitely?
There was a problem hiding this comment.
The update function would only update the entry within the dict (whose key is a combination of the logger level and the text) - so the dictionary would only have the max length of the number of Logger.log*_throttles
This idea works only until the text within the log is not static, and in the worst case changing for every log (e.g. a timestamp).
As a safety-net I could add the clearing of the dict from all entries that are older than e.g. one hour (as the entries are {log_id: timestamp})?
There was a problem hiding this comment.
I think it would be sufficient as a safety-net to just check whether the number of dict entries exceeds a certain limit and then remove entries. As long as the limit is not exceeded, it's probably fine to keep old entries.
As a further idea, I would suggest to log a warning message if the size limit is reached because, as you pointed out, this would likely be caused by improper usage of the throttle such as a non-static messages.
|
Would it be reasonable to include a limit on dictionary size? |
…avior_engine to github.com/FlexBE
|
@pschillinger ping :) |
|
@HannesBachter , with @pschillinger comments incorporated, would you be willing to submit a PR against the Noetic branch at https://github.com/FlexBE/flexbe_behavior_engine . That's where we are maintaining the behavior engine going forward. I'll take care of getting in to the ROS 2 branches. I don't plan to make changes to this old version. |
4a24142 to
55025a6
Compare
|
Opened a new PR here: FlexBE/flexbe_behavior_engine#14 |
adds the option to use
Logger.log*_throttle