Skip to content

Commit 8db2fc2

Browse files
committed
fix: parameterise stage key
Signed-off-by: Danju Visvanathan <danju.visvanathan@gmail.com>
1 parent 7a39376 commit 8db2fc2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

openfeature/hook/logging_hook.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(
1616
self.logger = logger or logging.getLogger("openfeature")
1717
self.include_evaluation_context = include_evaluation_context
1818

19-
def _build_args(self, hook_context: HookContext) -> dict:
19+
def _build_args(self, hook_context: HookContext, stage: str) -> dict:
2020
args = {
2121
"domain": hook_context.client_metadata.domain
2222
if hook_context.client_metadata
@@ -26,6 +26,7 @@ def _build_args(self, hook_context: HookContext) -> dict:
2626
else None,
2727
"flag_key": hook_context.flag_key,
2828
"default_value": hook_context.default_value,
29+
"stage": stage,
2930
}
3031
if self.include_evaluation_context:
3132
args["evaluation_context"] = json.dumps(
@@ -40,8 +41,7 @@ def _build_args(self, hook_context: HookContext) -> dict:
4041
def before(
4142
self, hook_context: HookContext, hints: HookHints
4243
) -> EvaluationContext | None:
43-
args = self._build_args(hook_context)
44-
args["stage"] = "before"
44+
args = self._build_args(hook_context, "before")
4545
self.logger.debug("Before stage %s", args)
4646
return None
4747

@@ -51,8 +51,7 @@ def after(
5151
details: FlagEvaluationDetails[FlagValueType],
5252
hints: HookHints,
5353
) -> None:
54-
args = self._build_args(hook_context)
55-
args["stage"] = "after"
54+
args = self._build_args(hook_context, "after")
5655
args["reason"] = details.reason
5756
args["variant"] = details.variant
5857
args["value"] = details.value
@@ -61,7 +60,7 @@ def after(
6160
def error(
6261
self, hook_context: HookContext, exception: Exception, hints: HookHints
6362
) -> None:
64-
args = self._build_args(hook_context)
63+
args = self._build_args(hook_context, "error")
6564
args["stage"] = "error"
6665
args["error_code"] = (
6766
exception.error_code

0 commit comments

Comments
 (0)