Skip to content

Commit

Permalink
[flexbe_msgs] [flexbe_core] Add debug level to logger
Browse files Browse the repository at this point in the history
(see #101)
  • Loading branch information
pschillinger committed Mar 1, 2020
1 parent 3ffe3ba commit b4b386f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
26 changes: 17 additions & 9 deletions flexbe_core/src/flexbe_core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Logger(object):
REPORT_WARN = BehaviorLog.WARN
REPORT_HINT = BehaviorLog.HINT
REPORT_ERROR = BehaviorLog.ERROR
REPORT_DEBUG = BehaviorLog.DEBUG

LOGGING_TOPIC = 'flexbe/log'

Expand All @@ -42,20 +43,27 @@ def log(text, severity):
rospy.loginfo('\033[94mBehavior Hint: %s\033[0m', text)
elif severity == Logger.REPORT_ERROR:
rospy.logerr(text)

elif severity == Logger.REPORT_DEBUG:
rospy.logdebug(text)
else:
rospy.logdebug(text + ' (unknown log level %s)' % str(severity))

@staticmethod
@staticmethod
def logdebug(text):
Logger.log(text, Logger.REPORT_DEBUG)

@staticmethod
def loginfo(text):
Logger.log(text, Logger.REPORT_INFO)
@staticmethod

@staticmethod
def logwarn(text):
Logger.log(text, Logger.REPORT_WARN)
@staticmethod

@staticmethod
def loghint(text):
Logger.log(text, Logger.REPORT_HINT)
@staticmethod

@staticmethod
def logerr(text):
Logger.log(text, Logger.REPORT_ERROR)
Logger.log(text, Logger.REPORT_ERROR)
1 change: 1 addition & 0 deletions flexbe_msgs/msg/BehaviorLog.msg
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ uint8 INFO = 0
uint8 WARN = 1
uint8 HINT = 2
uint8 ERROR = 3
uint8 DEBUG = 10

uint8 status_code

0 comments on commit b4b386f

Please sign in to comment.