Skip to content

Commit

Permalink
Disable verbose default logging from Boto3 in TLS installer (#2299)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2299

This change updates Boto3 primary loggers to only emit `WARNING` logs. The default value is `DEBUG` and is too verbose.

Differential Revision: D46002349

fbshipit-source-id: 2a37ea9aa4a6bd7a44559a52ed40ed86378d3d7c
  • Loading branch information
danbunnell authored and facebook-github-bot committed May 19, 2023
1 parent e9854c6 commit 15d37f3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docker/onedocker/prod/plugins/tls_cert_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ def _get_secret(secret_id: str, region: str) -> str:
return secret_svc.get_secret(secret_id).value


def _set_boto_log_level(log_level: int) -> None:
"""Sets the log level for all Boto3 loggers. The default value is DEBUG.
Arguments:
log_level: A logging log level
"""
logging.getLogger("boto3").setLevel(log_level)
logging.getLogger("boto").setLevel(log_level)
logging.getLogger("botocore").setLevel(log_level)


def main() -> None:
logger = logging.getLogger()
streamHandler = logging.StreamHandler(sys.stdout)
Expand All @@ -56,6 +67,9 @@ def main() -> None:
streamHandler.setFormatter(formatter)
logger.addHandler(streamHandler)

# disable verbose default logging from boto
_set_boto_log_level(logging.WARNING)

logging.info("Reading certificate content from environment variables...")
server_certificate = _get_env_var_if_set(SERVER_CERTIFICATE, "")
server_certificate_path = _get_env_var_if_set(SERVER_CERTIFICATE_PATH, "")
Expand Down

0 comments on commit 15d37f3

Please sign in to comment.