Skip to content

Commit

Permalink
remove the log throttle changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ggallagher01 committed May 9, 2017
1 parent 71f587e commit ce667df
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions clients/rospy/src/rospy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
from rospy.impl.validators import ParameterInvalid

from rosgraph_msgs.msg import Log
from functools import partial
from collections import namedtuple

_logger = logging.getLogger("rospy.core")

Expand Down Expand Up @@ -181,12 +179,10 @@ def _base_logger(msg, *args, **kwargs):

class LoggingThrottle(object):

LogEntry = namedtuple("LogEntry", "time digest")
last_logging_time_table = {}

last_log_entry = {}

def __call__(self, caller_id, logging_func, period, msg, *args):
"""Do logging specified message periodically. Messages with different contents will bypass throttling
def __call__(self, caller_id, logging_func, period, msg):
"""Do logging specified message periodically.
- caller_id (str): Id to identify the caller
- logging_func (function): Function to do logging.
Expand All @@ -195,12 +191,12 @@ def __call__(self, caller_id, logging_func, period, msg, *args):
"""
now = rospy.Time.now()

last = self.last_log_entry.get(caller_id, self.LogEntry(time=None, digest=None))
digest = hash(*args + tuple([str(msg)]))
last_logging_time = self.last_logging_time_table.get(caller_id)

if (last.time is None or (now - last.time) > rospy.Duration(period) or digest != last.digest):
logging_func(msg, *args)
self.last_log_entry[caller_id] = self.LogEntry(time=now, digest=digest)
if (last_logging_time is None or
(now - last_logging_time) > rospy.Duration(period)):
logging_func(msg)
self.last_logging_time_table[caller_id] = now


_logging_throttle = LoggingThrottle()
Expand Down

0 comments on commit ce667df

Please sign in to comment.