From 032a56372a7bb51bb3047338d307d073e78df9e9 Mon Sep 17 00:00:00 2001 From: Drew Banin Date: Tue, 27 Feb 2018 16:42:08 -0500 Subject: [PATCH] whitelist loggers instead of blacklisting nonexhaustively (#663) --- dbt/logger.py | 20 +++++++++++--------- scripts/dbt | 1 - 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/dbt/logger.py b/dbt/logger.py index 7ce14b7ca7e..301c3a72bc3 100644 --- a/dbt/logger.py +++ b/dbt/logger.py @@ -5,14 +5,6 @@ import colorama -# disable logs from other modules, excepting CRITICAL logs -logging.getLogger('botocore').setLevel(logging.CRITICAL) -logging.getLogger('contracts').setLevel(logging.CRITICAL) -logging.getLogger('requests').setLevel(logging.CRITICAL) -logging.getLogger('urllib3').setLevel(logging.CRITICAL) -logging.getLogger('google').setLevel(logging.CRITICAL) -logging.getLogger('snowflake.connector').setLevel(logging.CRITICAL) -logging.getLogger('parsedatetime').setLevel(logging.CRITICAL) # Colorama needs some help on windows because we're using logger.info # intead of print(). If the Windows env doesn't have a TERM var set, @@ -36,9 +28,14 @@ stdout_handler.setFormatter(logging.Formatter('%(message)s')) stdout_handler.setLevel(logging.INFO) -logger = logging.getLogger() +logger = logging.getLogger('dbt') logger.addHandler(stdout_handler) logger.setLevel(logging.DEBUG) +logging.getLogger().setLevel(logging.CRITICAL) + +# Redirect warnings through our logging setup +# They will be logged to a file below +logging.captureWarnings(True) initialized = False @@ -90,6 +87,11 @@ def initialize_logger(debug_mode=False, path=None): logger.addHandler(logdir_handler) + # Log Python warnings to file + warning_logger = logging.getLogger('py.warnings') + warning_logger.addHandler(logdir_handler) + warning_logger.setLevel(logging.DEBUG) + initialized = True diff --git a/scripts/dbt b/scripts/dbt index 7632227ae6e..dacb9cbc365 100644 --- a/scripts/dbt +++ b/scripts/dbt @@ -4,5 +4,4 @@ import dbt.main import logging if __name__ == "__main__": - logging.basicConfig(level=logging.INFO) dbt.main.main(sys.argv[1:])