Log errors and show them in the blender UI
This commit is contained in:
parent
d4463a3611
commit
57660631b5
|
@ -29,6 +29,7 @@ else:
|
|||
|
||||
info_text = ''
|
||||
num_warnings = 0
|
||||
num_errors = 0
|
||||
|
||||
def clear(clear_warnings=False):
|
||||
global info_text, num_warnings
|
||||
|
@ -62,4 +63,6 @@ def warn(text):
|
|||
print_warn(text)
|
||||
|
||||
def error(text):
|
||||
global num_errors
|
||||
num_errors += 1
|
||||
log('ERROR: ' + text, ERROR)
|
||||
|
|
|
@ -560,7 +560,19 @@ class ARM_PT_ArmoryPlayerPanel(bpy.types.Panel):
|
|||
box = layout.box()
|
||||
# Less spacing between lines
|
||||
col = box.column(align=True)
|
||||
col.label(text=f'{log.num_warnings} warnings occurred during compilation!', icon='ERROR')
|
||||
warnings = 'warnings' if log.num_warnings > 1 else 'warning'
|
||||
col.label(text=f'{log.num_warnings} {warnings} occurred during compilation!', icon='ERROR')
|
||||
# Blank icon to achieve the same indentation as the line before
|
||||
# prevent showing "open console" twice:
|
||||
if log.num_errors == 0:
|
||||
col.label(text='Please open the console to get more information.', icon='BLANK1')
|
||||
|
||||
if log.num_errors > 0:
|
||||
box = layout.box()
|
||||
# Less spacing between lines
|
||||
col = box.column(align=True)
|
||||
errors = 'errors' if log.num_errors > 1 else 'error'
|
||||
col.label(text=f'{log.num_errors} {errors} occurred during compilation!', icon='CANCEL')
|
||||
# Blank icon to achieve the same indentation as the line before
|
||||
col.label(text='Please open the console to get more information.', icon='BLANK1')
|
||||
|
||||
|
|
Loading…
Reference in a new issue