def start_device_logging(self, devicefile):
self.logger.info(_("received request to start logging on device {}").format(
devicefile))
# create the object path name on the bus name
objectpath = "/".join([CO2MONITOR_OBJECTPATH,
utils.devicefile2objectname(devicefile)])
# check if device is already monitored
monitored_devices = self.get_monitored_devices_objects()
if objectpath in monitored_devices:
self.logger.warning(" ".join([
_("There is already a logging thread for device {}."),
_("This is odd... I better do nothing.")
]).format(devicefile))
return False
else:
try:
thread = LogThread(devicefile = devicefile) # logger object
self.logger.info(_("starting logging thread for device {}").format(
devicefile))
# same logger as service
thread.set_logger(self.logger)
# same config as service
thread.set_config(self.config)
thread.daemon = True # let this thread be a daemon thread
thread.start()
except OSError:
self.logger.critical(_("Could not access the device file '{}'."
).format(devicefile))
return False
except:
self.logger.critical(_(
"Something went wrong with device file '{}'."
).format(devicefile))
return False
return True
评论列表
文章目录