logging: Serverside timestamping of messages
This commit is contained in:
parent
53685969d6
commit
1c74d2e50b
|
@ -1,5 +1,6 @@
|
|||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
import datetime
|
||||
import logging
|
||||
import octoprint.plugin
|
||||
import octoprint.plugin.core
|
||||
|
@ -42,10 +43,21 @@ class KlipperPlugin(
|
|||
message = ""
|
||||
|
||||
def logInfo(self, message):
|
||||
self._plugin_manager.send_plugin_message(self._identifier, dict(type="info", message=message))
|
||||
self._plugin_manager.send_plugin_message(
|
||||
self._identifier,
|
||||
dict(
|
||||
time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
type="info", message=message)
|
||||
)
|
||||
|
||||
def logError(self, error):
|
||||
self._plugin_manager.send_plugin_message(self._identifier, dict(type="error", message=error))
|
||||
self._plugin_manager.send_plugin_message(
|
||||
self._identifier,
|
||||
dict(
|
||||
time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
type="error",
|
||||
message=error)
|
||||
)
|
||||
|
||||
def on_parse_gcode(self, comm, line, *args, **kwargs):
|
||||
if "//" in line:
|
||||
|
|
|
@ -11,15 +11,7 @@ $(function() {
|
|||
self.shortStatus = ko.observable();
|
||||
|
||||
self.logMessages = ko.observableArray();
|
||||
/*
|
||||
self.onConnectToHost = function() {
|
||||
console.log("Connecting");
|
||||
self.shortStatus("Connecting to Host");
|
||||
OctoPrint.connection.connect({"port" : "VIRTUAL"});
|
||||
self.connectButtonText("Disconnect");
|
||||
console.log(self.loginState);
|
||||
}*/
|
||||
|
||||
|
||||
self.onGetStatus = function() {
|
||||
self.shortStatus("Update Status")
|
||||
OctoPrint.control.sendGcode("Status")
|
||||
|
@ -49,11 +41,11 @@ $(function() {
|
|||
|
||||
self.onDataUpdaterPluginMessage = function(plugin, message) {
|
||||
//console.log(message);
|
||||
self.logMessage(message["message"]);
|
||||
self.logMessage(message["time"], message["type"], message["message"]);
|
||||
}
|
||||
|
||||
self.logMessage = function(message) {
|
||||
self.logMessages.push({time: Date.now(), msg: message});
|
||||
self.logMessage = function(timestamp, type, message) {
|
||||
self.logMessages.push({time: timestamp, type: type, msg: message});
|
||||
}
|
||||
|
||||
self.onClearLog = function() {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<label>Log <span class="label label-success" data-bind="text: shortStatus">Connected</span> </label>
|
||||
<hr>
|
||||
<div class="plugin_klipper_msg" data-bind="foreach: logMessages">
|
||||
<div><i data-bind="text: formatDate(time)"></i> <span data-bind="text: msg"></span></div>
|
||||
<div><i data-bind="text: time"></i> <span data-bind="text: msg"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span4">
|
||||
|
@ -13,7 +13,8 @@
|
|||
<label>Restart</label>
|
||||
<button class="btn btn-block" data-bind="click: onRestartHost, enable: isActive()"><i class="fa fa-repeat"></i> Host</button>
|
||||
<button class="btn btn-block" data-bind="click: onRestartFirmware, enable: isActive()"><i class="fa fa-repeat"></i> MCU</button>
|
||||
<button class="btn btn-block" data-bind="click: onClearLog"><i class="fa fa-trash"></i> Clear Log</button>
|
||||
<label>Log</label>
|
||||
<button class="btn btn-block" data-bind="click: onClearLog"><i class="fa fa-trash"></i> Clear</button>
|
||||
</div>
|
||||
<hr>
|
||||
<div>
|
||||
|
|
Loading…
Reference in New Issue