Skip to content

Commit

Permalink
Merge branch 'blender-v4.3-release'
Browse files Browse the repository at this point in the history
  • Loading branch information
julienduroure committed Oct 31, 2024
2 parents e189740 + b76c8d8 commit 318eb80
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
14 changes: 12 additions & 2 deletions addons/io_scene_gltf2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (4, 4, 8),
"version": (4, 4, 9),
'blender': (4, 3, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
Expand Down Expand Up @@ -991,6 +991,12 @@ class ExportGLTF2_Base(ConvertGLTF2_Base):
default=False
)

export_loglevel: IntProperty(
name='Log Level',
description="Log Level",
default=-1,
)

# Custom scene property for saving settings
scene_key = "glTF2ExportSettings"

Expand Down Expand Up @@ -1076,7 +1082,11 @@ def execute(self, context):
# All custom export settings are stored in this container.
export_settings = {}

export_settings['loglevel'] = set_debug_log()
# Get log level from parameters
# If not set, get it from Blender app debug value
export_settings['gltf_loglevel'] = self.export_loglevel
if export_settings['gltf_loglevel'] < 0:
export_settings['loglevel'] = set_debug_log()

export_settings['exported_images'] = {}
export_settings['exported_texture_nodes'] = []
Expand Down
16 changes: 13 additions & 3 deletions addons/io_scene_gltf2/io/com/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import time
import logging
import logging.handlers
import sys

#
# Globals
Expand Down Expand Up @@ -75,22 +76,30 @@ def profile_end(label=None):
class Log:
def __init__(self, loglevel):
self.logger = logging.getLogger('glTFImporter')
self.error_logger = logging.getLogger('glTFImporter_errors')

# For console display
self.console_handler = logging.StreamHandler()
self.console_handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter('%(asctime)s | %(levelname)s: %(message)s', "%H:%M:%S")
self.console_handler.setFormatter(formatter)

# For console display - errors
self.error_console_handler = logging.StreamHandler(sys.stderr)
formatter_error = logging.Formatter('%(asctime)s | %(levelname)s: %(message)s', "%H:%M:%S")
self.error_console_handler.setFormatter(formatter_error)

# For popup display
self.popup_handler = logging.handlers.MemoryHandler(1024 * 10)

self.logger.addHandler(self.console_handler)
self.error_logger.addHandler(self.error_console_handler)
# self.logger.addHandler(self.popup_handler) => Make sure to not attach the popup handler to the logger

self.logger.setLevel(int(loglevel))
self.error_logger.setLevel(logging.ERROR)

def error(self, message, popup=False):
self.logger.error(message)
self.error_logger.error(message)
if popup:
self.popup_handler.buffer.append(('ERROR', message))

Expand All @@ -110,7 +119,7 @@ def debug(self, message, popup=False):
self.popup_handler.buffer.append(('DEBUG', message))

def critical(self, message, popup=False):
self.logger.critical(message)
self.error_logger.critical(message)
if popup:
# There is no Critical level in Blender, so we use error
self.popup_handler.buffer.append(('ERROR', message))
Expand All @@ -125,5 +134,6 @@ def messages(self):

def flush(self):
self.logger.removeHandler(self.console_handler)
self.error_logger.removeHandler(self.error_console_handler)
self.popup_handler.flush()
self.logger.removeHandler(self.popup_handler)

0 comments on commit 318eb80

Please sign in to comment.