5 from flexbe_msgs.msg
import BehaviorLog
11 @author: Philipp Schillinger 15 Realizes behavior-specific logging. 17 REPORT_INFO = BehaviorLog.INFO
18 REPORT_WARN = BehaviorLog.WARN
19 REPORT_HINT = BehaviorLog.HINT
20 REPORT_ERROR = BehaviorLog.ERROR
22 LOGGING_TOPIC =
'flexbe/log' 24 _last_status_update =
None 29 Logger._pub = ProxyPublisher({Logger.LOGGING_TOPIC: BehaviorLog})
32 def log(text, severity):
33 if Logger._last_status_update
is not None:
34 elapsed = rospy.get_rostime() - Logger._last_status_update;
35 if (elapsed.to_sec() < 0.1):
37 Logger._last_status_update = rospy.get_rostime()
41 msg.status_code = severity
42 Logger._pub.publish(Logger.LOGGING_TOPIC, msg)
44 if severity == Logger.REPORT_INFO:
46 elif severity == Logger.REPORT_WARN:
48 elif severity == Logger.REPORT_HINT:
49 rospy.loginfo(
'\033[94mBehavior Hint: %s\033[0m', text)
50 elif severity == Logger.REPORT_ERROR:
56 Logger.log(text, Logger.REPORT_INFO)
60 Logger.log(text, Logger.REPORT_WARN)
64 Logger.log(text, Logger.REPORT_HINT)
68 Logger.log(text, Logger.REPORT_ERROR)