Package org.togglz.core.logging
Class LoggingStateRepository
java.lang.Object
org.togglz.core.logging.LoggingStateRepository
- All Implemented Interfaces:
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 Summary
ConstructorsModifierConstructorDescriptionLoggingStateRepository(StateRepository delegate) Creates a logging facade for the suppliedStateRepository.LoggingStateRepository(StateRepository delegate, String customLogMessage) Creates a logging facade for the suppliedStateRepositoryusing a custom log message.protectedLoggingStateRepository(StateRepository delegate, String customLogMessage, org.slf4j.Logger log) protectedLoggingStateRepository(StateRepository delegate, org.slf4j.Logger log) -
Method Summary
Modifier and TypeMethodDescriptiongetFeatureState(Feature feature) Get the persisted state of a feature from the repository.voidsetFeatureState(FeatureState featureState) Persist the supplied feature state.
-
Constructor Details
-
LoggingStateRepository
Creates a logging facade for the suppliedStateRepository.- Parameters:
delegate- The repository to delegate invocations to
-
LoggingStateRepository
Creates a logging facade for the suppliedStateRepositoryusing 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 tocustomLogMessage- 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
-
LoggingStateRepository
protected LoggingStateRepository(StateRepository delegate, String customLogMessage, org.slf4j.Logger log)
-
-
Method Details
-
getFeatureState
Description copied from interface:StateRepositoryGet the persisted state of a feature from the repository. If the repository doesn't contain any information regarding this feature it must returnnull.- Specified by:
getFeatureStatein interfaceStateRepository- Parameters:
feature- The feature to read the state for- Returns:
- The persisted feature state or
null
-
setFeatureState
Description copied from interface:StateRepositoryPersist the supplied feature state. The repository implementation must ensure that subsequent calls toStateRepository.getFeatureState(Feature)return the same state as persisted using this method.- Specified by:
setFeatureStatein interfaceStateRepository- Parameters:
featureState- The feature state to persist
-