logging.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 import vigir_footstep_planning_msgs.msg
5 
6 from python_qt_binding.QtCore import Qt, QObject, Signal, Slot
7 from python_qt_binding.QtGui import QWidget, QColor
8 
9 from vigir_footstep_planning_msgs.msg import ErrorStatus
10 
11 
12 # Logging System
13 class Logger(QObject):
14 
15  out_log_signal = Signal(str, QColor)
16 
17  def __init__(self, error_status_text_box=None):
18  super(Logger, self).__init__()
19  self.connect(error_status_text_box)
20 
21  def connect(self, error_status_text_box):
22  if type(error_status_text_box).__name__ == "QErrorStatusTextBox":
23  self.out_log_signal.connect(error_status_text_box.out_log)
24  elif type(error_status_text_box).__name__ == "QErrorStatusWidget":
25  self.out_log_signal.connect(error_status_text_box.get_text_box().out_log)
26 
27  def log(self, error_status):
28  if error_status.error != 0:
29  self.log_error(error_status.error_msg)
30  if error_status.warning != 0:
31  self.log_warn(error_status.warning_msg)
32 
33  def log_info(self, msg):
34  self.out_log_signal.emit("[ INFO] " + msg, Qt.black)
35  rospy.loginfo(msg)
36 
37  def log_debug(self, msg):
38  self.out_log_signal.emit("[DEBUG] " + msg, Qt.yellow)
39  rospy.logdebug(msg)
40 
41  def log_warn(self, msg):
42  self.out_log_signal.emit("[ WARN] " + msg, QColor(255, 165, 0))
43  rospy.logwarn(msg)
44 
45  def log_error(self, msg):
46  self.out_log_signal.emit("[ERROR] " + msg, Qt.red)
47  rospy.logerr(msg)
48 
49 
50 # widget including logger
51 class QWidgetWithLogger(QWidget):
52 
53  logger = Logger()
54 
55  def __init__(self, parent=None, logger=Logger()):
56  QWidget.__init__(self, parent)
57  self.set_logger(logger)
58 
59  def set_logger(self, logger):
60  self.logger = logger
def __init__(self, parent=None, logger=Logger())
Definition: logging.py:55
def __init__(self, error_status_text_box=None)
Definition: logging.py:17
def connect(self, error_status_text_box)
Definition: logging.py:21


vigir_footstep_planning_lib
Author(s): Alexander Stumpf
autogenerated on Mon Jun 10 2019 15:47:33