java.lang.Object
dev.openfeature.sdk.hooks.logging.LoggingHook
A hook for logging flag evaluations.
Useful for debugging.
Flag evaluation data is logged at debug and error in before/after stages and error stages, respectively.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new LoggingHook.LoggingHook(boolean includeEvaluationContext) Construct a new LoggingHook. -
Method Summary
Modifier and TypeMethodDescriptionvoidafter(HookContext<Object> hookContext, FlagEvaluationDetails<Object> details, Map<String, Object> hints) Runs after a flag is resolved.Runs before flag is resolved.voidRun when evaluation encounters an error.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.openfeature.sdk.Hook
finallyAfter, supportsFlagValueType
-
Constructor Details
-
LoggingHook
public LoggingHook()Construct a new LoggingHook. -
LoggingHook
public LoggingHook(boolean includeEvaluationContext) Construct a new LoggingHook.- Parameters:
includeEvaluationContext- include a serialized evaluation context in the log message (defaults to false)
-
-
Method Details
-
before
public Optional<EvaluationContext> before(HookContext<Object> hookContext, Map<String, Object> hints) Description copied from interface:HookRuns before flag is resolved.- Specified by:
beforein interfaceHook<Object>- Parameters:
hookContext- Information about the particular flag evaluationhints- An immutable mapping of data for users to communicate to the hooks.- Returns:
- An optional
EvaluationContext. If returned, it will be merged with the EvaluationContext instances from other hooks, the client and API.
-
after
public void after(HookContext<Object> hookContext, FlagEvaluationDetails<Object> details, Map<String, Object> hints) Description copied from interface:HookRuns after a flag is resolved. -
error
Description copied from interface:HookRun when evaluation encounters an error. This will always run. Errors thrown will be swallowed.
-