Skip to content

Commit

Permalink
Merge pull request #14 from fictivekin/logging-updates
Browse files Browse the repository at this point in the history
Replace warn logging with info/error
  • Loading branch information
jperras authored Jul 20, 2023
2 parents e035374 + 47278f3 commit 0a3479c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions dynaconf_aws_loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,17 @@ def _fetch_single_parameter(
try:
value = client.get_parameter(Name=path, WithDecryption=True)
except ClientError as exc:
if exc.response.get("Error", {}).get("Code") == "ParameterNotFound":
logger.warn("Parameter with path %s does not exist in AWS SSM." % path)
if silent:
return
if exc.response.get("Error", {}).get("Code") == "ParameterNotFound":
logger.info("Parameter with path %s does not exist in AWS SSM." % path)
raise
except BotoCoreError:
logger.warn(
"Could not connect to AWS SSM at endpoint %s." % client.meta.endpoint_url
)
if silent:
return
logger.error(
"Could not connect to AWS SSM at endpoint %s." % client.meta.endpoint_url
)
raise

if data := value.get("Parameter"):
Expand Down Expand Up @@ -264,17 +264,17 @@ def _fetch_all_parameters(
data.append({parameter["Name"]: parameter["Value"]})

except ClientError as exc:
if exc.response.get("Error", {}).get("Code") == "ParameterNotFound":
logger.warn("Parameter with path %s does not exist in AWS SSM." % path)
if silent:
return
if exc.response.get("Error", {}).get("Code") == "ParameterNotFound":
logger.info("Parameter with path %s does not exist in AWS SSM." % path)
raise
except BotoCoreError:
logger.warn(
"Could not connect to AWS SSM at endpoint %s." % client.meta.endpoint_url
)
if silent:
return
logger.error(
"Could not connect to AWS SSM at endpoint %s." % client.meta.endpoint_url
)
raise

result = parse_conf_data(data=slashes_to_dict(data), tomlfy=True)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_fetch_single_parameter_missing(stubbed_client, caplog):

with stubbed_client:
with pytest.raises(stubbed_client.client.exceptions.ParameterNotFound):
with caplog.at_level(logging.WARN, logger="dynaconf.aws_loader"):
with caplog.at_level(logging.INFO, logger="dynaconf.aws_loader"):
_fetch_single_parameter(
stubbed_client.client,
project_prefix="foobar",
Expand All @@ -146,7 +146,7 @@ def test_fetch_single_parameter_missing(stubbed_client, caplog):
assert caplog.record_tuples == [
(
"dynaconf.aws_loader",
logging.WARN,
logging.INFO,
"Parameter with path /foobar/testing/baldur does not exist in AWS SSM.",
)
]
Expand All @@ -166,7 +166,7 @@ def test_fetch_all_parameters_missing(stubbed_client, caplog):

with stubbed_client:
with pytest.raises(stubbed_client.client.exceptions.ParameterNotFound):
with caplog.at_level(logging.WARN, logger="dynaconf.aws_loader"):
with caplog.at_level(logging.INFO, logger="dynaconf.aws_loader"):
_fetch_all_parameters(
stubbed_client.client,
project_prefix="foobar",
Expand All @@ -177,7 +177,7 @@ def test_fetch_all_parameters_missing(stubbed_client, caplog):
assert caplog.record_tuples == [
(
"dynaconf.aws_loader",
logging.WARN,
logging.INFO,
"Parameter with path /foobar/testing does not exist in AWS SSM.",
)
]
Expand Down

0 comments on commit 0a3479c

Please sign in to comment.