logging: Basic logging of status response

This commit is contained in:
Martin Muehlhaeuser 2018-01-23 17:33:22 +00:00
parent 7b9331d271
commit 1696cd43c6
2 changed files with 32 additions and 23 deletions

View File

@ -36,26 +36,36 @@ class KlipperPlugin(
css=["css/klipper.css"],
less=["css/klipper.less"]
)
parsingReturn = False
message = ""
def logInfo(self, message):
self._plugin_manager.send_plugin_message(self._identifier, dict(type="info", message=message))
def logError(self, error):
self._plugin_manager.send_plugin_message(self._identifier, dict(type="error", message=error))
def on_parse_gcode(self, comm, line, *args, **kwargs):
if "ok" not in line:
return line
self._plugin_manager.send_plugin_message(self._identifier, dict(message=line))
#from octoprint.util.comm import parse_firmware_line
# Create a dict with all the keys/values returned by the M115 request
#printer_data = parse_firmware_line(line)
self._logger.info("Machine type detected {line}.".format(line=line))
#self._logger.info("Machine type detected: {machine}.".format(machine=printer_data["MACHINE_TYPE"]))
if "!!" in line:
self.logError(line.strip('!'))
else:
if "//" in line:
self.parsingReturn = True
self.message = self.message + line.strip('/')
else:
if self.parsingReturn:
self.parsingReturn = False
self.logInfo(self.message)
self.message = ""
return line
def on_printer_action(self, comm, line, action, *args, **kwargs):
#if not action == "custom":
# return
self._logger.info("action recieved:".action)
self._plugin_manager.send_plugin_message(self._identifier, dict(message=line))
self._plugin_manager.send_plugin_message(self._identifier, dict(message=action))
#self._logger.info("action recieved:".action)
__plugin_name__ = "Klipper"

View File

@ -22,35 +22,34 @@ $(function() {
self.onGetStatus = function() {
self.shortStatus("Update Status")
OctoPrint.control.sendGcode("Status")
}
self.onRestartFirmware = function() {
//OctoPrint.control.sendGcode("FIRMWARE_RESTART")
self.logMessage("Restarted Firmware");
self.shortStatus("Restarting Firmware");
console.log("Restart firmware");
OctoPrint.control.sendGcode("FIRMWARE_RESTART")
};
self.onRestartHost = function() {
self.shortStatus("Restarting Host");
console.log("Restart Host");
self.logMessage("Restarted Host");
//OctoPrint.control.sendGcode("RESTART")
self.shortStatus("Restarting Host");
OctoPrint.control.sendGcode("RESTART")
};
self.onBeforeBinding = function() {
self.connectionState.selectedPort("VIRTUAL");
//self.connectionState.selectedPort("VIRTUAL");
}
self.onAfterBinding = function() {
self.connectionState.selectedPort("VIRTUAL");
self.connectionState.selectedPort(self.settings.settings.plugins.klipper.serialport());
console.log(self.connectionState.selectedPort());
self.shortStatus("Idle");
}
self.onDataUpdaterPluginMessage = function(plugin, message) {
//console.log(message);
self.logMessage("plugin: " +plugin+ " message recieved: " + message["message"]);
self.logMessage(message["message"]);
}
self.logMessage = function(message) {