mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 02:25:54 +08:00
Merge pull request #16773 from Ultimaker/CURA-11064_plugin_specific_log_files
Cura 11064 plugin specific log files
This commit is contained in:
commit
4551cb3f5f
@ -1,6 +1,7 @@
|
|||||||
# Copyright (c) 2023 Ultimaker B.V.
|
# Copyright (c) 2023 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
import socket
|
import socket
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ from UM.Settings.AdditionalSettingDefinitionAppender import AdditionalSettingDef
|
|||||||
from UM.PluginObject import PluginObject
|
from UM.PluginObject import PluginObject
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
from UM.Platform import Platform
|
from UM.Platform import Platform
|
||||||
|
from UM.Resources import Resources
|
||||||
|
|
||||||
|
|
||||||
class BackendPlugin(AdditionalSettingDefinitionsAppender, PluginObject):
|
class BackendPlugin(AdditionalSettingDefinitionsAppender, PluginObject):
|
||||||
@ -71,11 +73,23 @@ 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()}")
|
with open(plugin_log_path, 'a') as f:
|
||||||
popen_kwargs = {"stdin": None }
|
popen_kwargs = {
|
||||||
|
"stdin": None,
|
||||||
|
"stdout": f, # Redirect output to file
|
||||||
|
"stderr": subprocess.STDOUT, # Combine stderr and stdout
|
||||||
|
}
|
||||||
if Platform.isWindows():
|
if Platform.isWindows():
|
||||||
popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW
|
popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW
|
||||||
self._process = subprocess.Popen(self._validatePluginCommand(), **popen_kwargs)
|
self._process = subprocess.Popen(self._validatePluginCommand(), **popen_kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user