Skip to content

Commit 8e33f4d

Browse files
committed
Patch 0.4.1
Added logs filter so it no longer handle messages from modules external to the addon
1 parent 96b127c commit 8e33f4d

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
bl_info = {
22
"name": "NR_Cleanup",
33
"author": "Bigthirsty & Skyrow",
4-
"version": (0, 4, 0), #<major>.<minor>.<patch>
4+
"version": (0, 4, 1), #<major>.<minor>.<patch>
55
"blender": (3, 6, 0),
66
"location": "3D Viewport > Sidebar > NR Cleanup",
77
"description": "Cleans up NinjaRipped trackmania2020 maps to driving surfaces only",
88
"category": "Trackmania",
99
}
1010

1111
ROOT_PATH = __file__
12-
LOG_DEBUG = True
12+
LOG_DEBUG = False
1313

1414

1515
import bpy

operators/preferences/OT_nrc_do_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def execute(self, context):
1616
if AddonUpdate.can_update:
1717
AddonUpdate.do_update()
1818

19-
if AddonUpdate.update_successfull:
19+
if AddonUpdate.update_successful:
2020
self.report({'INFO'}, f'{bl_info["name"]}: update successful, blender must be restarted.')
2121
else:
2222
self.report({'ERROR'}, f'{bl_info["name"]}: update error, try again later. If the problem persists, save logs and contact staff.')

panels/PT_nrc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def draw(self, context):
1919

2020
layout = self.layout
2121
row = layout.row(align=True)
22-
if AddonUpdate.update_successfull:
22+
if AddonUpdate.update_successful:
2323
row.label(text='Blender must be restarted !', icon ='FILE_SCRIPT')
2424
else:
2525
row.label(text=f'{current_version_str}', icon='FILE_SCRIPT')

utils/logs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ def formatStack(self, stack_info) -> str:
117117
return f'<span class="si">{html.escape(super().formatStack(stack_info))}</span>'
118118

119119

120+
#---------------------------------------------------------------------------
121+
# Filter class
122+
#---------------------------------------------------------------------------
123+
124+
class _LogsPackageFilter(logging.Filter):
125+
126+
def filter(record):
127+
return record.name.startswith(__package__)
128+
129+
120130
#---------------------------------------------------------------------------
121131
# Logging initialization
122132
#---------------------------------------------------------------------------
@@ -174,10 +184,12 @@ def formatStack(self, stack_info) -> str:
174184
_console_handler = logging.StreamHandler()
175185
_console_handler.setLevel(_level)
176186
_console_handler.setFormatter(_ConsoleStyleFormatter(_fmt))
187+
_console_handler.addFilter(_LogsPackageFilter)
177188

178189
_html_handler = logging.FileHandler(filename=html_logs_filepath, mode='a', encoding='utf-8')
179190
_html_handler.setLevel(_level)
180191
_html_handler.setFormatter(_HtmlStyleFormatter(fmt=_fmt))
192+
_html_handler.addFilter(_LogsPackageFilter)
181193

182194
# Set root logger level
183195
_root_logger = logging.getLogger()

utils/update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AddonUpdate():
3737
new_addon_available:bool = False
3838
current_blender_supported:bool = False
3939
can_update: bool = False
40-
update_successfull = False
40+
update_successful = False
4141

4242
@classmethod
4343
def check_can_update(cls) :
@@ -120,5 +120,5 @@ def on_rmtree_error(function, path, excinfo):
120120
log.exception('Error during addon update')
121121

122122
else:
123-
cls.update_successfull = True
123+
cls.update_successful = True
124124
log.info('Addon updated, blender must be restarted.')

0 commit comments

Comments
 (0)