logging.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import rospy
00004 import vigir_footstep_planning_msgs.msg
00005 
00006 from python_qt_binding.QtCore import Qt, QObject, Signal, Slot
00007 from python_qt_binding.QtGui import QWidget, QColor
00008 
00009 from vigir_footstep_planning_msgs.msg import ErrorStatus
00010 
00011 
00012 # Logging System
00013 class Logger(QObject):
00014 
00015     out_log_signal = Signal(str, QColor)
00016 
00017     def __init__(self, error_status_text_box=None):
00018         super(Logger, self).__init__()
00019         self.connect(error_status_text_box)
00020 
00021     def connect(self, error_status_text_box):
00022         if type(error_status_text_box).__name__ == "QErrorStatusTextBox":
00023             self.out_log_signal.connect(error_status_text_box.out_log)
00024         elif type(error_status_text_box).__name__ == "QErrorStatusWidget":
00025             self.out_log_signal.connect(error_status_text_box.get_text_box().out_log)
00026 
00027     def log(self, error_status):
00028         if error_status.error != 0:
00029             self.log_error(error_status.error_msg)
00030         if error_status.warning != 0:
00031             self.log_warn(error_status.warning_msg)
00032 
00033     def log_info(self, msg):
00034         self.out_log_signal.emit("[ INFO] " + msg, Qt.black)
00035         rospy.loginfo(msg)
00036 
00037     def log_debug(self, msg):
00038         self.out_log_signal.emit("[DEBUG] " + msg, Qt.yellow)
00039         rospy.logdebug(msg)
00040 
00041     def log_warn(self, msg):
00042         self.out_log_signal.emit("[ WARN] " + msg, QColor(255, 165, 0))
00043         rospy.logwarn(msg)
00044 
00045     def log_error(self, msg):
00046         self.out_log_signal.emit("[ERROR] " + msg, Qt.red)
00047         rospy.logerr(msg)
00048 
00049 
00050 # widget including logger
00051 class QWidgetWithLogger(QWidget):
00052 
00053     logger = Logger()
00054 
00055     def __init__(self, parent=None, logger=Logger()):
00056         QWidget.__init__(self, parent)
00057         self.set_logger(logger)
00058 
00059     def set_logger(self, logger):
00060         self.logger = logger


vigir_footstep_planning_lib
Author(s): Alexander Stumpf
autogenerated on Sat Jul 15 2017 02:47:56