@@ -57,7 +57,7 @@ def _match_by_action(self, action: str, condition_value: Any, context_value: Any
5757 func = mapping_by_action .get (action , lambda a , b : False )
5858 return func (context_value , condition_value )
5959 except Exception as exc :
60- self .loggerdebug (f"caught exception while matching action: action={ action } , exception={ str (exc )} " )
60+ self .logger . debug (f"caught exception while matching action: action={ action } , exception={ str (exc )} " )
6161 return False
6262
6363 def _evaluate_conditions (
@@ -68,7 +68,7 @@ def _evaluate_conditions(
6868 conditions = cast (List [Dict ], rule .get (schema .CONDITIONS_KEY ))
6969
7070 if not conditions :
71- self .loggerdebug (
71+ self .logger . debug (
7272 f"rule did not match, no conditions to match, rule_name={ rule_name } , rule_value={ rule_match_value } , "
7373 f"name={ feature_name } "
7474 )
@@ -80,13 +80,13 @@ def _evaluate_conditions(
8080 cond_value = condition .get (schema .CONDITION_VALUE )
8181
8282 if not self ._match_by_action (action = cond_action , condition_value = cond_value , context_value = context_value ):
83- self .loggerdebug (
83+ self .logger . debug (
8484 f"rule did not match action, rule_name={ rule_name } , rule_value={ rule_match_value } , "
8585 f"name={ feature_name } , context_value={ str (context_value )} "
8686 )
8787 return False # context doesn't match condition
8888
89- self .loggerdebug (f"rule matched, rule_name={ rule_name } , rule_value={ rule_match_value } , name={ feature_name } " )
89+ self .logger . debug (f"rule matched, rule_name={ rule_name } , rule_value={ rule_match_value } , name={ feature_name } " )
9090 return True
9191
9292 def _evaluate_rules (
@@ -97,12 +97,12 @@ def _evaluate_rules(
9797 rule_match_value = rule .get (schema .RULE_MATCH_VALUE )
9898
9999 # Context might contain PII data; do not log its value
100- self .loggerdebug (f"Evaluating rule matching, rule={ rule_name } , feature={ feature_name } , default={ feat_default } " )
100+ self .logger . debug (f"Evaluating rule matching, rule={ rule_name } , feature={ feature_name } , default={ feat_default } " )
101101 if self ._evaluate_conditions (rule_name = rule_name , feature_name = feature_name , rule = rule , context = context ):
102102 return bool (rule_match_value )
103103
104104 # no rule matched, return default value of feature
105- self .loggerdebug (f"no rule matched, returning feature default, default={ feat_default } , name={ feature_name } " )
105+ self .logger . debug (f"no rule matched, returning feature default, default={ feat_default } , name={ feature_name } " )
106106 return feat_default
107107 return False
108108
@@ -149,7 +149,7 @@ def get_configuration(self) -> Union[Dict[str, Dict], Dict]:
149149 ```
150150 """
151151 # parse result conf as JSON, keep in cache for max age defined in store
152- self .loggerdebug (f"Fetching schema from registered store, store={ self ._store } " )
152+ self .logger . debug (f"Fetching schema from registered store, store={ self ._store } " )
153153 config = self ._store .get_configuration ()
154154 validator = schema .SchemaValidator (schema = config )
155155 validator .validate ()
@@ -193,21 +193,21 @@ def evaluate(self, *, name: str, context: Optional[Dict[str, Any]] = None, defau
193193 try :
194194 features = self .get_configuration ()
195195 except ConfigurationStoreError as err :
196- self .loggerdebug (f"Failed to fetch feature flags from store, returning default provided, reason={ err } " )
196+ self .logger . debug (f"Failed to fetch feature flags from store, returning default provided, reason={ err } " )
197197 return default
198198
199199 feature = features .get (name )
200200 if feature is None :
201- self .loggerdebug (f"Feature not found; returning default provided, name={ name } , default={ default } " )
201+ self .logger . debug (f"Feature not found; returning default provided, name={ name } , default={ default } " )
202202 return default
203203
204204 rules = feature .get (schema .RULES_KEY )
205205 feat_default = feature .get (schema .FEATURE_DEFAULT_VAL_KEY )
206206 if not rules :
207- self .loggerdebug (f"no rules found, returning feature default, name={ name } , default={ feat_default } " )
207+ self .logger . debug (f"no rules found, returning feature default, name={ name } , default={ feat_default } " )
208208 return bool (feat_default )
209209
210- self .loggerdebug (f"looking for rule match, name={ name } , default={ feat_default } " )
210+ self .logger . debug (f"looking for rule match, name={ name } , default={ feat_default } " )
211211 return self ._evaluate_rules (feature_name = name , context = context , feat_default = bool (feat_default ), rules = rules )
212212
213213 def get_enabled_features (self , * , context : Optional [Dict [str , Any ]] = None ) -> List [str ]:
@@ -244,20 +244,20 @@ def get_enabled_features(self, *, context: Optional[Dict[str, Any]] = None) -> L
244244 try :
245245 features : Dict [str , Any ] = self .get_configuration ()
246246 except ConfigurationStoreError as err :
247- self .loggerdebug (f"Failed to fetch feature flags from store, returning empty list, reason={ err } " )
247+ self .logger . debug (f"Failed to fetch feature flags from store, returning empty list, reason={ err } " )
248248 return features_enabled
249249
250- self .loggerdebug ("Evaluating all features" )
250+ self .logger . debug ("Evaluating all features" )
251251 for name , feature in features .items ():
252252 rules = feature .get (schema .RULES_KEY , {})
253253 feature_default_value = feature .get (schema .FEATURE_DEFAULT_VAL_KEY )
254254 if feature_default_value and not rules :
255- self .loggerdebug (f"feature is enabled by default and has no defined rules, name={ name } " )
255+ self .logger . debug (f"feature is enabled by default and has no defined rules, name={ name } " )
256256 features_enabled .append (name )
257257 elif self ._evaluate_rules (
258258 feature_name = name , context = context , feat_default = feature_default_value , rules = rules
259259 ):
260- self .loggerdebug (f"feature's calculated value is True, name={ name } " )
260+ self .logger . debug (f"feature's calculated value is True, name={ name } " )
261261 features_enabled .append (name )
262262
263263 return features_enabled
0 commit comments