Skip to content

Commit

Permalink
whitelist loggers instead of blacklisting nonexhaustively (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbanin authored and cmcarthur committed Feb 27, 2018
1 parent 4eb75ec commit 032a563
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 11 additions & 9 deletions dbt/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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


Expand Down
1 change: 0 additions & 1 deletion scripts/dbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ import dbt.main
import logging

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
dbt.main.main(sys.argv[1:])

0 comments on commit 032a563

Please sign in to comment.