summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xCHANGES.txt3
-rw-r--r--SCons/Tool/MSCommon/common.py36
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())