✨ New plugin timings logging feature

If enabled (via Settings > Server > Debug options) this will write two
new files to the logging dir, plugintimings.log and plugintimings.csv,
which contain timing information for each and every hook or
implementation call on plugins registered with OctoPrint. This should
be helpful to debug any kind of performance issues caused by third
party plugins. It should also be a valuable tool to debug performance
issues with bundled plugins.

As requested in #1241
This commit is contained in:
Gina Häußge committed 2020-09-30 13:58:47 +02:00
1 parent 24204efab6
commit 22ce8e4c24
15 files changed
+153 -20

No files matched your search

+5 -1
View File
@@ -52,9 +52,11 @@ class LoggingPlugin(octoprint.plugin.AssetPlugin,
loggers = self._get_available_loggers()
levels = self._get_logging_levels()
serial_log_enabled = self._settings.global_get_boolean(["serial", "log"])
plugintimings_log_enabled = self._settings.global_get_boolean(["devel", "pluginTimings"])
return jsonify(logs=dict(files=files, free=free, total=total),
setup=dict(loggers=loggers, levels=levels),
serial_log=dict(enabled=serial_log_enabled))
serial_log=dict(enabled=serial_log_enabled),
plugintimings_log=dict(enabled=plugintimings_log_enabled))
@octoprint.plugin.BlueprintPlugin.route("/logs", methods=["GET"])
@no_firstrun_access
@@ -213,6 +215,8 @@ class LoggingPlugin(octoprint.plugin.AssetPlugin,
def get_template_configs(self):
return [
dict(type="navbar", template="logging_navbar_seriallog.jinja2", suffix="_seriallog"),
dict(type="navbar", template="logging_navbar_plugintimingslog.jinja2", suffix="_plugintimingslog"),
dict(type="settings", custom_bindings=True)
]
@@ -11,6 +11,7 @@ $(function() {
self.configuredLoggers = ko.observableArray();
self.configuredLoggersChanged = false;
self.serialLogEnabled = ko.observable();
self.pluginTimingsLogEnabled = ko.observable();
self.freeSpace = ko.observable(undefined);
self.totalSpace = ko.observable(undefined);
@@ -70,6 +71,7 @@ $(function() {
self.fromLogsResponse(response.logs);
self.fromSetupResponse(response.setup);
self.fromSerialLogResponse(response.serial_log);
self.fromPluginTimingsLogResponse(response.plugintimings_log);
};
self.fromLogsResponse = function(response) {
@@ -112,16 +114,30 @@ $(function() {
self.serialLogEnabled(response.enabled);
};
self.popoverContent = function() {
self.fromPluginTimingsLogResponse = function(response) {
if (!response) return;
self.pluginTimingsLogEnabled(response.enabled);
};
self.serialLogPopoverContent = function() {
return self.popoverContent("serial.log");
};
self.pluginTimingsLogPopoverContent = function() {
return self.popoverContent("plugintimings.log");
};
self.popoverContent = function(logfile) {
var free = self.freeSpace();
var total = self.totalSpace();
var content = "<p>"
+ gettext("You currently have <code>serial.log</code> enabled. Please remember to turn it off " +
"again once your are done debugging whatever issue prompted you to turn it on.")
+ _.sprintf(gettext("You currently have <code>%(logfile)s</code> enabled. Please remember to turn it off " +
"again once your are done debugging whatever issue prompted you to turn it on."), {logfile: logfile})
+ "</p><p>"
+ 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 " +
"depending on how long you keep it enabled and thus should only be used for " +
"debugging.")
+ "</p>";
@@ -133,7 +149,7 @@ $(function() {
}
return content;
};
}
self.configuredLoggersHasChanged = function () {
self.configuredLoggersChanged = true;
@@ -279,6 +295,6 @@ $(function() {
construct: LoggingViewModel,
additionalNames: ["logsViewModel"],
dependencies: ["loginStateViewModel", "accessViewModel"],
elements: ["#settings_plugin_logging", "#navbar_plugin_logging"]
elements: ["#settings_plugin_logging", "#navbar_plugin_logging_seriallog", "#navbar_plugin_logging_plugintimingslog"]
});
});
@@ -0,0 +1,3 @@
<a href="https://faq.octoprint.org/plugintimings-log" target="_blank" title="{{ _('plugintimings.log is enabled') }}" rel="noopener noreferrer" data-bind="visible: pluginTimingsLogEnabled(), popover: { placement: 'bottom', title: '{{ _('<code>plugintimings.log</code> is enabled')|esq }}', html: true, content: pluginTimingsLogPopoverContent, trigger: 'hover' }" style="display: none">
<i class="fa fa-file-text"></i>
</a>
@@ -1,3 +1,3 @@
<a href="https://faq.octoprint.org/serial-log" target="_blank" title="{{ _('serial.log is enabled') }}" rel="noopener noreferrer" data-bind="visible: serialLogEnabled(), popover: { placement: 'bottom', title: '{{ _('<code>serial.log</code> is enabled')|esq }}', html: true, content: popoverContent, trigger: 'hover' }" style="display: none">
<a href="https://faq.octoprint.org/serial-log" target="_blank" title="{{ _('serial.log is enabled') }}" rel="noopener noreferrer" data-bind="visible: serialLogEnabled(), popover: { placement: 'bottom', title: '{{ _('<code>serial.log</code> is enabled')|esq }}', html: true, content: serialLogPopoverContent, trigger: 'hover' }" style="display: none">
<i class="fa fa-file-text"></i>
</a>