package at.asitplus.eidas.specific.core.logger; import java.util.Collections; import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import com.google.common.collect.Sets; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.IStatusMessenger; import at.gv.egiz.eaaf.core.api.idp.IAuthData; import at.gv.egiz.eaaf.core.api.logging.IStatisticLogger; /** * {@link IStatisticLogger} implementation that can log into more than one internal {@link IStatisticLogger}. * * @author tlenz * */ public class MultipleStatisticLogger implements IStatisticLogger { private final Set internalLoggers; /** * Build a statistic logger that logs into {@link StatisticLogger} and {@link AdvancedStatisticLogger}. * * @param messageService i18n message-source implementation. */ public MultipleStatisticLogger(@Autowired IStatusMessenger messageService) { internalLoggers = Collections.unmodifiableSet( Sets.newHashSet( new StatisticLogger(), new AdvancedStatisticLogger(messageService))); } @Override public void logSuccessOperation(IRequest protocolRequest, IAuthData authData, boolean isSsoSession) { internalLoggers.parallelStream() .forEach(el -> el.logSuccessOperation(protocolRequest, authData, isSsoSession)); } @Override public void logErrorOperation(Throwable throwable) { internalLoggers.parallelStream().forEach(el -> el.logErrorOperation(throwable)); } @Override public void logErrorOperation(Throwable throwable, IRequest errorRequest) { internalLoggers.parallelStream().forEach(el -> el.logErrorOperation(throwable, errorRequest)); } @Override public void internalTesting() throws Exception { for (IStatisticLogger el : internalLoggers) { el.internalTesting(); } } }