From 6e7f1530dedce1445e4d5d9640abaf293ac8032d Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Fri, 7 Aug 2020 07:09:26 -0400 Subject: Remove hard-coded MSCommon from debug logging record filename field. Add method to retrieve truncated relative module file name path. Add filter and derived path field for debug log record processing to produce the correct relative file name information for calls to debug from above MSCommon (e.g, msvsTests). --- CHANGES.txt | 4 ++++ SCons/Tool/MSCommon/common.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7250a9b..eae76c8 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,10 @@ NOTE: The 4.0.0 Release of SCons dropped Python 2.7 Support RELEASE VERSION/DATE TO BE FILLED IN LATER + From Joseph Brill: + - Modify the MSCommon internal-use only debug logging records to contain the correct relative + file path when the debug function is called from outside the MSCommon module. + From William Deegan: - Fix yacc tool, not respecting YACC set at time of tool initialization. diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index e1a82f2..81004df 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -42,19 +42,46 @@ if LOGFILE == '-': print(message) elif LOGFILE: import logging + modulelist = ( + # root module and parent/root module + 'MSCommon', 'Tool', + # python library and below: correct iff scons does not have a lib folder + 'lib', + # scons modules + 'SCons', 'test', 'scons' + ) + def get_relative_filename(filename, module_list): + if not filename: + return filename + for module in module_list: + try: + ind = filename.rindex(module) + return filename[ind:] + except ValueError: + pass + return filename + class _Debug_Filter(logging.Filter): + # custom filter for module relative filename + def filter(self, record): + relfilename = get_relative_filename(record.pathname, modulelist) + relfilename = relfilename.replace('\\', '/') + record.relfilename = relfilename + return True logging.basicConfig( # This looks like: # 00109ms:MSCommon/vc.py:find_vc_pdir#447: format=( '%(relativeCreated)05dms' - ':MSCommon/%(filename)s' + ':%(relfilename)s' ':%(funcName)s' '#%(lineno)s' ':%(message)s: ' ), filename=LOGFILE, level=logging.DEBUG) - debug = logging.getLogger(name=__name__).debug + logger = logging.getLogger(name=__name__) + logger.addFilter(_Debug_Filter()) + debug = logger.debug else: def debug(x): return None -- cgit v0.12 From d97ab435efedef58940aed901303e5e2a89f76c5 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Mon, 10 Aug 2020 12:08:25 -0400 Subject: Restore inadvertent character changes from master. [ci skip] --- CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index c1ee31f..8a8cc24 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ - + SCons - a software construction tool -- cgit v0.12