def update(self, work_unit, attribute, value): """Receives updates from monitored WorkUnits. Given updates for monitored WorkUnits, this method transforms a WorkUnit update into a log message. It logs all calls to this method at DEBUG level, passing all arguments. It then logs formatted messages at INFO level recording the status of the WorkUnit being updated. Args: work_unit: The WorkUnit that was updated. attribute: The attribute who's value was updated. value: The new attribute value. """ self.log_debug( 'Received an update - WorkUnit: %s, Attr: %s, Value: %s' % (work_unit.name, attribute, value), work_unit.name) if work_unit.get_status() == enums.Status.RUNNING: running = enums.status_to_string(work_unit.get_status()) self.log_info( '%s: %s - %s of %s' % (running, work_unit.name, work_unit.complete, work_unit.total), work_unit.name) else: status_string = enums.status_to_string(work_unit.get_status()) self.log_info('%s: %s' % (status_string, work_unit.name), work_unit.name)
def update(self, work_unit, attribute, value): """Receives updates from monitored WorkUnits. Given updates for monitored WorkUnits, this method transforms a WorkUnit update into a log message. It logs all calls to this method at DEBUG level, passing all arguments. It then logs formatted messages at INFO level recording the status of the WorkUnit being updated. Args: work_unit: The WorkUnit that was updated. attribute: The attribute who's value was updated. value: The new attribute value. """ self.log_debug( 'Received an update - WorkUnit: %s, Attr: %s, Value: %s' % ( work_unit.name, attribute, value), work_unit.name) if work_unit.get_status() == enums.Status.RUNNING: running = enums.status_to_string(work_unit.get_status()) self.log_info( '%s: %s - %s of %s' % ( running, work_unit.name, work_unit.complete, work_unit.total), work_unit.name) else: status_string = enums.status_to_string(work_unit.get_status()) self.log_info( '%s: %s' % (status_string, work_unit.name), work_unit.name)
def should_listen(self, work_unit): """All work_units should be listened to. Args: work_unit: The WorkUnit this listener is being asked to listen to. Returns: Returns True if the WorkUnit should be observed by this LogSource. """ self.log_debug( 'Adding listener to WorkUnit named \'%s\' with a status of %s.' % (work_unit.name, enums.status_to_string(work_unit.get_status())), work_unit.name) self.log_info( '%s: Logging %s' % (enums.status_to_string(work_unit.get_status()), work_unit.name), work_unit.name) return True
def should_listen(self, work_unit): """All work_units should be listened to. Args: work_unit: The WorkUnit this listener is being asked to listen to. Returns: Returns True if the WorkUnit should be observed by this LogSource. """ self.log_debug( 'Adding listener to WorkUnit named \'%s\' with a status of %s.' % (work_unit.name, enums.status_to_string(work_unit.get_status())), work_unit.name) self.log_info( '%s: Logging %s' % ( enums.status_to_string(work_unit.get_status()), work_unit.name), work_unit.name) return True