mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Add logging and cleanup for backend plugins
This commit adds improved logging for backend plugins in Cura. Now, each time a plugin is started, an info log is generated with the used command. All plugin output will also be logged to a separate file for easier debugging. Additionally, a cleanup operation has been added to remove existing plugin logs before generating a new one, to prevent the file size from getting too large. Contributes to CURA-11064
This commit is contained in:
parent
a9f2d879f7
commit
e9f316d5d9
1 changed files with 8 additions and 3 deletions
|
@ -73,12 +73,17 @@ class BackendPlugin(AdditionalSettingDefinitionsAppender, PluginObject):
|
||||||
"""
|
"""
|
||||||
if not self.usePlugin():
|
if not self.usePlugin():
|
||||||
return False
|
return False
|
||||||
|
Logger.info(f"Starting backend_plugin [{self._plugin_id}] with command: {self._validatePluginCommand()}")
|
||||||
|
plugin_log_path = os.path.join(Resources.getDataStoragePath(), f"{self.getPluginId()}.log")
|
||||||
|
if os.path.exists(plugin_log_path):
|
||||||
|
try:
|
||||||
|
os.remove(plugin_log_path)
|
||||||
|
except:
|
||||||
|
pass # removing is only done such that it doesn't grow out of proportions, if it fails once or twice that is okay
|
||||||
|
Logger.info(f"Logging plugin output to: {plugin_log_path}")
|
||||||
try:
|
try:
|
||||||
# STDIN needs to be None because we provide no input, but communicate via a local socket instead.
|
# STDIN needs to be None because we provide no input, but communicate via a local socket instead.
|
||||||
# The NUL device sometimes doesn't exist on some computers.
|
# The NUL device sometimes doesn't exist on some computers.
|
||||||
Logger.info(f"Starting backend_plugin [{self._plugin_id}] with command: {self._validatePluginCommand()}")
|
|
||||||
plugin_log_path = os.path.join(Resources.getDataStoragePath(), f"{self.getPluginId()}.log")
|
|
||||||
Logger.info(f"Logging plugin output to: {plugin_log_path}")
|
|
||||||
with open(plugin_log_path, 'a') as f:
|
with open(plugin_log_path, 'a') as f:
|
||||||
popen_kwargs = {
|
popen_kwargs = {
|
||||||
"stdin": None,
|
"stdin": None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue