From f2c025d668b9d0b09f75a9d79020c1a987bf1f11 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Sat, 30 Apr 2022 12:46:44 -0400 Subject: Use the logging framework for mscommon debug output to stdout --- CHANGES.txt | 3 +++ SCons/Tool/MSCommon/common.py | 36 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 510e0e6..415212b 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -17,6 +17,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER default compiler to MSVC which wasn't installed, yielding broken build. Updated mingw tool so that the generate and exists methods use the same mingw search paths (issue #4134). + - Update the internal mscommon debug handling for stdout to use the logging framework. Update + the debug record format so that the output logged to stdout contains the output that is logged + to a file. From William Deegan: - Fix check for unsupported Python version. It was broken. Also now the error message diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index ee31b2d..c5cf232 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -37,14 +37,7 @@ import SCons.Util # SCONS_MSCOMMON_DEBUG is internal-use so undocumented: # set to '-' to print to console, else set to filename to log to LOGFILE = os.environ.get('SCONS_MSCOMMON_DEBUG') -if LOGFILE == '-': - def debug(message, *args): - if args: - print(message % args) - else: - print(message) - -elif LOGFILE: +if LOGFILE: import logging modulelist = ( # root module and parent/root module @@ -71,17 +64,24 @@ elif LOGFILE: relfilename = relfilename.replace('\\', '/') record.relfilename = relfilename return True + # Log format looks like: + # 00109ms:MSCommon/vc.py:find_vc_pdir#447: VC found '14.3' [file] + # debug:00109ms:MSCommon/vc.py:find_vc_pdir#447: VC found '14.3' [stdout] + log_format=( + '%(relativeCreated)05dms' + ':%(relfilename)s' + ':%(funcName)s' + '#%(lineno)s' + ': %(message)s' + ) + if LOGFILE == '-': + log_format = 'debug:' + log_format + log_handler = logging.StreamHandler(sys.stdout) + else: + log_handler = logging.FileHandler(filename=LOGFILE) logging.basicConfig( - # This looks like: - # 00109ms:MSCommon/vc.py:find_vc_pdir#447:VC found '14.3' - format=( - '%(relativeCreated)05dms' - ':%(relfilename)s' - ':%(funcName)s' - '#%(lineno)s' - ':%(message)s' - ), - filename=LOGFILE, + format=log_format, + handlers=[log_handler], level=logging.DEBUG) logger = logging.getLogger(name=__name__) logger.addFilter(_Debug_Filter()) -- cgit v0.12 From e4545999ed50c1df21f0d2daab48f0fbfbe19259 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Sat, 30 Apr 2022 17:16:02 -0400 Subject: Add space to stdout debug prefix for logging record. --- SCons/Tool/MSCommon/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index c5cf232..c3ab6ad 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -75,7 +75,7 @@ if LOGFILE: ': %(message)s' ) if LOGFILE == '-': - log_format = 'debug:' + log_format + log_format = 'debug: ' + log_format log_handler = logging.StreamHandler(sys.stdout) else: log_handler = logging.FileHandler(filename=LOGFILE) -- cgit v0.12 From 03d49b630465628815ab4d24eedd8b5a7689e6d7 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Sat, 30 Apr 2022 17:46:29 -0400 Subject: Update debug record format comment for additional space. --- SCons/Tool/MSCommon/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index c3ab6ad..83bd2fd 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -65,8 +65,8 @@ if LOGFILE: record.relfilename = relfilename return True # Log format looks like: - # 00109ms:MSCommon/vc.py:find_vc_pdir#447: VC found '14.3' [file] - # debug:00109ms:MSCommon/vc.py:find_vc_pdir#447: VC found '14.3' [stdout] + # 00109ms:MSCommon/vc.py:find_vc_pdir#447: VC found '14.3' [file] + # debug: 00109ms:MSCommon/vc.py:find_vc_pdir#447: VC found '14.3' [stdout] log_format=( '%(relativeCreated)05dms' ':%(relfilename)s' -- cgit v0.12 From 2083d7f530ba95caa0aa5a95ec4702cc5a10aea6 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Tue, 3 May 2022 10:30:33 -0400 Subject: Update CHANGES.txt and add same to RELEASE.txt. [ci skip] --- CHANGES.txt | 8 +++++--- RELEASE.txt | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 415212b..6f518f0 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -17,9 +17,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER default compiler to MSVC which wasn't installed, yielding broken build. Updated mingw tool so that the generate and exists methods use the same mingw search paths (issue #4134). - - Update the internal mscommon debug handling for stdout to use the logging framework. Update - the debug record format so that the output logged to stdout contains the output that is logged - to a file. + - Update the debug output written to stdout for MSVC initialization which is enabled by setting + SCONS_MSCOMMON_DEBUG=- to use the logging module. Also changed the debug output format + written to stdout to include more information about the source for each message of MSVC + initialization debugging output. A single space was added before the message for all + debugging output records written to stdout and to files. From William Deegan: - Fix check for unsupported Python version. It was broken. Also now the error message diff --git a/RELEASE.txt b/RELEASE.txt index 49636bc..a4f15d9 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -42,6 +42,11 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY - The change to "content" and "content-timestamp" Decider names is reflected in the User Guide as well, since the hash function may be other than md5 (tidying up from earlier change) +- Update the debug output written to stdout for MSVC initialization which is enabled + by setting SCONS_MSCOMMON_DEBUG=- to use the logging module. Also changed the debug + output format written to stdout to include more information about the source for each + message of MSVC initialization debugging output. A single space was added before the + message for all debugging output records written to stdout and to files. FIXES -- cgit v0.12