Class LoggingStateRepository

java.lang.Object
org.togglz.core.logging.LoggingStateRepository
All Implemented Interfaces:
StateRepository

public class LoggingStateRepository extends Object implements StateRepository
Simple implementation of StateRepository which adds logging capabilities to an existing repository. You should consider using this class if you want to log all feature toggled events.
Author:
Martin Günther
  • Constructor Details

    • LoggingStateRepository

      public LoggingStateRepository(StateRepository delegate)
      Creates a logging facade for the supplied StateRepository.
      Parameters:
      delegate - The repository to delegate invocations to
    • LoggingStateRepository

      public LoggingStateRepository(StateRepository delegate, String customLogMessage)
      Creates a logging facade for the supplied StateRepository using a custom log message. In your custom log message, mark the position of the feature name as {1} and the position for the new feature state which will be replaced by "enabled" or "disabled" as {2}.
      Parameters:
      delegate - The repository to delegate invocations to
      customLogMessage - Your custom log message. It may contain a placeholder {1} for the feature name and a placeholder {2} for the new feature state which will be replaced by "enabled" or "disabled"
    • LoggingStateRepository

      protected LoggingStateRepository(StateRepository delegate, org.slf4j.Logger log)
    • LoggingStateRepository

      protected LoggingStateRepository(StateRepository delegate, String customLogMessage, org.slf4j.Logger log)
  • Method Details

    • getFeatureState

      public FeatureState getFeatureState(Feature feature)
      Description copied from interface: StateRepository
      Get the persisted state of a feature from the repository. If the repository doesn't contain any information regarding this feature it must return null.
      Specified by:
      getFeatureState in interface StateRepository
      Parameters:
      feature - The feature to read the state for
      Returns:
      The persisted feature state or null
    • setFeatureState

      public void setFeatureState(FeatureState featureState)
      Description copied from interface: StateRepository
      Persist the supplied feature state. The repository implementation must ensure that subsequent calls to StateRepository.getFeatureState(Feature) return the same state as persisted using this method.
      Specified by:
      setFeatureState in interface StateRepository
      Parameters:
      featureState - The feature state to persist