diff --git a/gestalt/vault.py b/gestalt/vault.py index 3c46e72..24e614d 100644 --- a/gestalt/vault.py +++ b/gestalt/vault.py @@ -1,3 +1,4 @@ +import logging import os from datetime import datetime, timedelta, timezone from queue import Queue @@ -14,6 +15,8 @@ EXPIRATION_THRESHOLD_HOURS = 1 +logger = logging.getLogger(__name__) + class Vault(Provider): @@ -93,7 +96,7 @@ def connect(self) -> None: ) if token is not None: - print("Kubernetes login successful") + logger.info("Kubernetes login successful") kubes_token = ( "kubernetes", token["data"]["id"], @@ -179,7 +182,7 @@ def get(self, match = jsonpath_expression.find(secret) if len(match) == 0: - print("Path returned not matches for your secret") + logger.warning("Path returned not matches for your secret") returned_value_from_secret: Union[str, int, float, List[Any]] = match[0].value @@ -236,11 +239,11 @@ def _validate_token_expiration(self) -> None: delta_time = (expire_time - current_time).total_seconds() / 3600 if delta_time < EXPIRATION_THRESHOLD_HOURS: - print(f"Re-authenticating with vault") + logger.info("Re-authenticating with vault") self.connect() else: - print(f"Token still valid for: {delta_time} hours") + logger.debug(f"Token still valid for: {delta_time} hours") else: - print( + logger.warning( f"Can't reconnect, token information: {self.kubes_token}, not valid" )