Redirect warnings to the logging system on python versions >= 2.6 Refs #3135.

This commit is contained in:
Pedro Algarvio 2013-01-04 11:36:57 +00:00
parent 44f207df1c
commit a71358e6df

View File

@ -181,6 +181,11 @@ if logging.getLoggerClass() is not Logging:
# No handlers could be found for logger "foo"
logging.getLogger().addHandler(LOGGING_NULL_HANDLER)
if sys.version_info > (2, 6):
# Python versions >= 2.6 allow warning to be redirected to the logging
# system. Let's enable it.
logging.captureWarnings(True)
def getLogger(name): # pylint: disable-msg=C0103
return logging.getLogger(name)