Skip to content

Commit b69a491

Browse files
author
L'In20Cible
committed
Cleaner patch for #211.
1 parent 07f75f4 commit b69a491

File tree

1 file changed

+6
-8
lines changed
  • addons/source-python/packages/source-python

1 file changed

+6
-8
lines changed

addons/source-python/packages/source-python/loggers.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,15 @@ def _log(self, level, msg, *args, **kwargs):
252252
# Print to the main SP log file?
253253
if SP_LOG & areas:
254254

255-
# Patch for issue #211.
256-
# Save/Overwrite the logger's name
257-
name = _sp_logger.logger.name
258-
_sp_logger.logger.name = self.logger.name
255+
# Get the given extra dictionary
256+
extra = kwargs.setdefault('extra', dict())
257+
258+
# Set the logger name
259+
extra.setdefault('logger_name', self.logger.name)
259260

260261
# Print to the SP log file
261262
_sp_logger.logger.log(level, msg, *args, **kwargs)
262263

263-
# Restore the name
264-
_sp_logger.logger.name = name
265-
266264
@staticmethod
267265
def _get_level_value(level):
268266
"""Return a level value used by the logging package.
@@ -406,7 +404,7 @@ def areas(self):
406404
_sp_logger = LogManager(
407405
'sp', _level, _areas,
408406
'source-python.{0}'.format(date.today().strftime('%Y-%m-%d')),
409-
'%(asctime)s - %(name)s\t-\t%(levelname)s\t%(message)s',
407+
'%(asctime)s - %(logger_name)s\t-\t%(levelname)s\t%(message)s',
410408
'%Y-%m-%d %H:%M:%S')
411409

412410
# Set the parent logger level to allow all message types

0 commit comments

Comments
 (0)