From 13f470b09a7b69969115fbe9e5687d021362ddb6 Mon Sep 17 00:00:00 2001 From: edubook007 Date: Tue, 7 Jun 2022 15:10:53 +0530 Subject: [PATCH] cache info logger added --- FeatureToggle/__init__.py | 6 ++++++ FeatureToggle/utils.py | 2 +- UnleashClient/utils.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/FeatureToggle/__init__.py b/FeatureToggle/__init__.py index c612743..302617f 100644 --- a/FeatureToggle/__init__.py +++ b/FeatureToggle/__init__.py @@ -148,6 +148,7 @@ def is_enabled_for_domain(feature_name: str, (bool): True if Feature is enabled else False """ feature_toggles = FeatureToggles.fetch_feature_toggles() + LOGGER.info(f"Enable_for_domain_FT_cache_info: {FeatureToggles.fetch_feature_toggles.__wrapped__.cache_info()}") return domain_name in feature_toggles.get(feature_name, {}).get('domain_names', []) @staticmethod @@ -162,6 +163,7 @@ def is_enabled_for_partner(feature_name: str, (bool): True if Feature is enabled else False """ feature_toggles = FeatureToggles.fetch_feature_toggles() + LOGGER.info(f"Enable_for_partner_FT_cache_info: {FeatureToggles.fetch_feature_toggles.__wrapped__.cache_info()}") return partner_name in feature_toggles.get(feature_name, {}).get('partner_names', []) @staticmethod @@ -176,6 +178,7 @@ def is_enabled_for_business(feature_name: str, (bool): True if Feature is enabled else False """ feature_toggles = FeatureToggles.fetch_feature_toggles() + LOGGER.info(f"Enable_for_business_FT_cache_info: {FeatureToggles.fetch_feature_toggles.__wrapped__.cache_info()}") return business_via_name in feature_toggles.get(feature_name, {}).get('business_via_names', []) @staticmethod @@ -190,6 +193,7 @@ def is_enabled_for_expert(feature_name: str, (bool): True if Feature is enabled else False """ feature_toggles = FeatureToggles.fetch_feature_toggles() + LOGGER.info(f"Enable_for_expert_FT_cache_info: {FeatureToggles.fetch_feature_toggles.__wrapped__.cache_info()}") return expert_email in feature_toggles.get(feature_name, {}).get('expert_emails', []) @staticmethod @@ -204,6 +208,7 @@ def is_enabled_for_team(feature_name: str, (bool): True if feature is enabled else False """ feature_toggles = FeatureToggles.fetch_feature_toggles() + LOGGER.info(f"Enable_for_team_FT_cache_info: {FeatureToggles.fetch_feature_toggles.__wrapped__.cache_info()}") return team_id in feature_toggles.get(feature_name, {}).get('team_ids', []) @staticmethod @@ -222,6 +227,7 @@ def fetch_feature_toggles(): """ # TODO: Remove the cas and environment name from the feature toggles while returning the response LOGGER.info(f'Loading Feature Toggles from Redis') + LOGGER.info(f"Efetch_feature_toggles_cache_info: {FeatureToggles.fetch_feature_toggles.__wrapped__.cache_info()}") if FeatureToggles.__cache is None: raise Exception( 'To update cache Feature Toggles class needs to be initialised' diff --git a/FeatureToggle/utils.py b/FeatureToggle/utils.py index b475bc9..4812b0d 100644 --- a/FeatureToggle/utils.py +++ b/FeatureToggle/utils.py @@ -1,4 +1,4 @@ -from UnleashClient import LOGGER +from UnleashClient.utils import LOGGER from datetime import datetime, timedelta from functools import lru_cache, wraps diff --git a/UnleashClient/utils.py b/UnleashClient/utils.py index 888db20..e411702 100644 --- a/UnleashClient/utils.py +++ b/UnleashClient/utils.py @@ -2,7 +2,7 @@ import mmh3 # pylint: disable=import-error from requests import Response -LOGGER = logging.getLogger(__name__) +LOGGER = logging.getLogger("mogambo") def normalized_hash(identifier: str,