diff --git a/src/octoprint/plugins/logging/__init__.py b/src/octoprint/plugins/logging/__init__.py index a6e7e95e5..d0cc01e69 100644 --- a/src/octoprint/plugins/logging/__init__.py +++ b/src/octoprint/plugins/logging/__init__.py @@ -51,8 +51,10 @@ class LoggingPlugin(octoprint.plugin.AssetPlugin, free, total = self._get_usage() loggers = self._get_available_loggers() levels = self._get_logging_levels() + serial_log_enabled = self._settings.global_get_boolean(["serial", "log"]) return jsonify(logs=dict(files=files, free=free, total=total), - setup=dict(loggers=loggers, levels=levels)) + setup=dict(loggers=loggers, levels=levels), + serial_log=dict(enabled=serial_log_enabled)) @octoprint.plugin.BlueprintPlugin.route("/logs", methods=["GET"]) @no_firstrun_access @@ -228,12 +230,7 @@ __plugin_disabling_discouraged__ = gettext("Without this plugin you will no long "the web interface.") __plugin_license__ = "AGPLv3" __plugin_pythoncompat__ = ">=2.7,<4" - -def __plugin_load__(): - global __plugin_implementation__ - __plugin_implementation__ = LoggingPlugin() - - global __plugin_hooks__ - __plugin_hooks__ = { - "octoprint.access.permissions": __plugin_implementation__.get_additional_permissions - } +__plugin_implementation__ = LoggingPlugin() +__plugin_hooks__ = { + "octoprint.access.permissions": __plugin_implementation__.get_additional_permissions +} diff --git a/src/octoprint/plugins/logging/static/js/logging.js b/src/octoprint/plugins/logging/static/js/logging.js index 7a7978ac7..7ed3f2bf1 100644 --- a/src/octoprint/plugins/logging/static/js/logging.js +++ b/src/octoprint/plugins/logging/static/js/logging.js @@ -8,6 +8,9 @@ $(function() { self.availableLoggersLevel = ko.observable(); self.configuredLoggers = ko.observableArray(); self.configuredLoggersChanged = false; + self.serialLogEnabled = ko.observable(); + self.freeSpace = ko.observable(undefined); + self.totalSpace = ko.observable(undefined); self.markedForDeletion = ko.observableArray([]); @@ -61,6 +64,7 @@ $(function() { self.fromResponse = function(response) { self.fromLogsResponse(response.logs); self.fromSetupResponse(response.setup); + self.fromSerialLogResponse(response.serial_log); }; self.fromLogsResponse = function(response) { @@ -71,6 +75,9 @@ $(function() { return; self.listHelper.updateItems(files); + + self.freeSpace(response.free); + self.totalSpace(response.total); }; self.fromSetupResponse = function(response) { @@ -94,6 +101,35 @@ $(function() { self.availableLoggers(availableLoggers); }; + self.fromSerialLogResponse = function(response) { + if (!response) return; + + self.serialLogEnabled(response.enabled); + }; + + self.popoverContent = function() { + var free = self.freeSpace(); + var total = self.totalSpace(); + + var content = "
"
+ + gettext("You currently have serial.log enabled. Please remember to turn it off " +
+ "again once your are done debugging whatever issue prompted you to turn it on.")
+ + "
" + + gettext("It can negatively impact print performance and also take up a lot of storage space " + + "depending on how long you stay connected to your printer and thus should only be used for " + + "debugging.") + + "
"; + + if (free !== undefined && total !== undefined) { + content += "" + gettext("Log storage:") + " " + + formatSize(free) + " / " + + formatSize(total) + + "
"; + } + + return content; + }; + self.configuredLoggersHasChanged = function () { self.configuredLoggersChanged = true; }; @@ -149,7 +185,7 @@ $(function() { perform); }; - self.onSettingsShown = function() { + self.onStartup = self.onServerReconnect = self.onUserLoggedIn = self.onUserLoggedOut = function() { self.requestData(); }; @@ -212,6 +248,6 @@ $(function() { construct: LoggingViewModel, additionalNames: ["logsViewModel"], dependencies: ["loginStateViewModel"], - elements: ["#settings_plugin_logging"] + elements: ["#settings_plugin_logging", "#navbar_plugin_logging"] }); }); diff --git a/src/octoprint/plugins/logging/templates/logging_navbar.jinja2 b/src/octoprint/plugins/logging/templates/logging_navbar.jinja2 new file mode 100644 index 000000000..f03a75d09 --- /dev/null +++ b/src/octoprint/plugins/logging/templates/logging_navbar.jinja2 @@ -0,0 +1,3 @@ + + + diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 973c3346a..fd655f2fd 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -323,7 +323,7 @@ default_settings = { "closeModalsWithClick": True, "components": { "order": { - "navbar": ["settings", "systemmenu", "plugin_announcements", "plugin_pi_support", "login"], + "navbar": ["settings", "systemmenu", "plugin_announcements", "plugin_logging", "plugin_pi_support", "login"], "sidebar": ["plugin_firmware_check", "connection", "state", "files"], "tab": ["temperature", "control", "gcodeviewer", "terminal", "timelapse"], "settings": [