Skip to content

Commit 1233966

Browse files
Gerald W. LesterGerald W. Lester
Gerald W. Lester
authored and
Gerald W. Lester
committed
Add missing period to logger.debug
1 parent 29633dc commit 1233966

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

aws_lambda_powertools/utilities/feature_flags/feature_flags.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

aws_lambda_powertools/utilities/feature_flags/schema.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def __init__(self, schema: Dict[str, Any], logger=None):
111111
self.logger = logger
112112

113113
def validate(self) -> None:
114-
self.loggerdebug("Validating schema")
114+
self.logger.debug("Validating schema")
115115
if not isinstance(self.schema, dict):
116116
raise SchemaValidationError(f"Features must be a dictionary, schema={str(self.schema)}")
117117

@@ -127,7 +127,7 @@ def __init__(self, schema: Dict):
127127

128128
def validate(self):
129129
for name, feature in self.schema.items():
130-
self.loggerdebug(f"Attempting to validate feature '{name}'")
130+
self.logger.debug(f"Attempting to validate feature '{name}'")
131131
self.validate_feature(name, feature)
132132
rules = RulesValidator(feature=feature)
133133
rules.validate()
@@ -152,14 +152,14 @@ def __init__(self, feature: Dict[str, Any]):
152152

153153
def validate(self):
154154
if not self.rules:
155-
self.loggerdebug("Rules are empty, ignoring validation")
155+
self.logger.debug("Rules are empty, ignoring validation")
156156
return
157157

158158
if not isinstance(self.rules, dict):
159159
raise SchemaValidationError(f"Feature rules must be a dictionary, feature={self.feature_name}")
160160

161161
for rule_name, rule in self.rules.items():
162-
self.loggerdebug(f"Attempting to validate rule '{rule_name}'")
162+
self.logger.debug(f"Attempting to validate rule '{rule_name}'")
163163
self.validate_rule(rule=rule, rule_name=rule_name, feature_name=self.feature_name)
164164
conditions = ConditionsValidator(rule=rule, rule_name=rule_name)
165165
conditions.validate()
@@ -201,7 +201,7 @@ def validate_condition(self,rule_name: str, condition: Dict[str, str]) -> None:
201201
raise SchemaValidationError(f"Feature rule condition must be a dictionary, rule={rule_name}")
202202

203203
# Condition can contain PII data; do not log condition value
204-
self.loggerdebug(f"Attempting to validate condition for '{rule_name}'")
204+
self.logger.debug(f"Attempting to validate condition for '{rule_name}'")
205205
ConditionsValidator.validate_condition_action(condition=condition, rule_name=rule_name)
206206
ConditionsValidator.validate_condition_key(condition=condition, rule_name=rule_name)
207207
ConditionsValidator.validate_condition_value(condition=condition, rule_name=rule_name)

0 commit comments

Comments
 (0)