Add a log entry for importing, duplicating or removing a material

We encountered an issue yesterday that we had to find in a log file when a user was importing a material. Nothing is shown in the log when importing a material, so it was impossible to find.
Now we'll log this action. It is a direct user action, so info is a good log level.
This commit is contained in:
Ghostkeeper 2021-06-04 02:51:13 +02:00
parent bb20e3307f
commit 2f8f98fcca
No known key found for this signature in database
GPG Key ID: D2A8871EE34EC59A
2 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# Copyright (c) 2019 Ultimaker B.V.
# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import copy # To duplicate materials.
@ -79,6 +79,7 @@ class MaterialManagementModel(QObject):
:param material_node: The material to remove.
"""
Logger.info(f"Removing material {material_node.container_id}")
container_registry = CuraContainerRegistry.getInstance()
materials_this_base_file = container_registry.findContainersMetadata(base_file = material_node.base_file)
@ -194,6 +195,7 @@ class MaterialManagementModel(QObject):
:return: The root material ID of the duplicate material.
"""
Logger.info(f"Duplicating material {material_node.base_file} to {new_base_id}")
return self.duplicateMaterialByBaseFile(material_node.base_file, new_base_id, new_metadata)
@pyqtSlot(result = str)

View File

@ -1,4 +1,4 @@
# Copyright (c) 2020 Ultimaker B.V.
# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import os
@ -241,6 +241,7 @@ class ContainerManager(QObject):
file_url = file_url_or_string.toLocalFile()
else:
file_url = file_url_or_string
Logger.info(f"Importing material from {file_url}")
if not file_url or not os.path.exists(file_url):
return {"status": "error", "message": "Invalid path"}