Skip to content

Commit

Permalink
Merge pull request #2635 from fishtown-analytics/feature/debug-loggin…
Browse files Browse the repository at this point in the history
…g-env-vars

add environment variables for logging
  • Loading branch information
beckjake authored Jul 20, 2020
2 parents 5e1b284 + 51f6c26 commit 0404881
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## dbt 0.17.2b1 (Release TBD)

### Features
- Added environment variables for debug-level logging ([#2633](https://github.com/fishtown-analytics/dbt/issues/2633), [#2635](https://github.com/fishtown-analytics/dbt/pull/2635))

## dbt 0.17.1 (July 20, 2020)

## dbt 0.17.1rc4 (July 08, 2020)
Expand Down
29 changes: 21 additions & 8 deletions core/dbt/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,15 +597,28 @@ def emit(self, record: logbook.LogRecord):
self.records.append(as_dict)


# we still need to use logging to suppress these or pytest captures them
logging.getLogger('botocore').setLevel(logging.ERROR)
logging.getLogger('requests').setLevel(logging.ERROR)
logging.getLogger('urllib3').setLevel(logging.ERROR)
logging.getLogger('google').setLevel(logging.ERROR)
logging.getLogger('snowflake.connector').setLevel(logging.ERROR)
def _env_log_level(var_name: str) -> int:
# convert debugging environment variable name to a log level
if dbt.flags.env_set_truthy(var_name):
return logging.DEBUG
else:
return logging.ERROR


LOG_LEVEL_GOOGLE = _env_log_level('DBT_GOOGLE_DEBUG_LOGGING')
LOG_LEVEL_SNOWFLAKE = _env_log_level('DBT_SNOWFLAKE_CONNECTOR_DEBUG_LOGGING')
LOG_LEVEL_BOTOCORE = _env_log_level('DBT_BOTOCORE_DEBUG_LOGGING')
LOG_LEVEL_HTTP = _env_log_level('DBT_HTTP_DEBUG_LOGGING')
LOG_LEVEL_WERKZEUG = _env_log_level('DBT_WERKZEUG_DEBUG_LOGGING')

logging.getLogger('botocore').setLevel(LOG_LEVEL_BOTOCORE)
logging.getLogger('requests').setLevel(LOG_LEVEL_HTTP)
logging.getLogger('urllib3').setLevel(LOG_LEVEL_HTTP)
logging.getLogger('google').setLevel(LOG_LEVEL_GOOGLE)
logging.getLogger('snowflake.connector').setLevel(LOG_LEVEL_SNOWFLAKE)

logging.getLogger('parsedatetime').setLevel(logging.ERROR)
# want to see werkzeug logs about errors
logging.getLogger('werkzeug').setLevel(logging.ERROR)
logging.getLogger('werkzeug').setLevel(LOG_LEVEL_WERKZEUG)


def list_handler(
Expand Down

0 comments on commit 0404881

Please sign in to comment.