Class LoggingHook

java.lang.Object
dev.openfeature.sdk.hooks.logging.LoggingHook
All Implemented Interfaces:
Hook<Object>

public class LoggingHook extends Object implements Hook<Object>
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 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: Hook
      Runs before flag is resolved.
      Specified by:
      before in interface Hook<Object>
      Parameters:
      hookContext - Information about the particular flag evaluation
      hints - 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: Hook
      Runs after a flag is resolved.
      Specified by:
      after in interface Hook<Object>
      Parameters:
      hookContext - Information about the particular flag evaluation
      details - Information about how the flag was resolved, including any resolved values.
      hints - An immutable mapping of data for users to communicate to the hooks.
    • error

      public void error(HookContext<Object> hookContext, Exception error, Map<String,Object> hints)
      Description copied from interface: Hook
      Run when evaluation encounters an error. This will always run. Errors thrown will be swallowed.
      Specified by:
      error in interface Hook<Object>
      Parameters:
      hookContext - Information about the particular flag evaluation
      error - The exception that was thrown.
      hints - An immutable mapping of data for users to communicate to the hooks.