All Downloads are FREE. Search and download functionalities are using the official Maven repository.

querqy.elasticsearch.infologging.SingleSinkInfoLogging Maven / Gradle / Ivy

package querqy.elasticsearch.infologging;

import querqy.infologging.InfoLogging;
import querqy.infologging.Sink;
import querqy.rewrite.SearchEngineRequestAdapter;

import java.util.Collections;
import java.util.Set;

public class SingleSinkInfoLogging implements InfoLogging {

    private final Sink sink;
    private final Set enabledRewriterIds;

    public SingleSinkInfoLogging(final Sink sink, final Set enabledRewriterIds) {
        this.sink = sink;
        this.enabledRewriterIds = enabledRewriterIds == null
                ? Collections.emptySet()
                : Collections.unmodifiableSet(enabledRewriterIds);
    }

    @Override
    public void log(final Object message, final String rewriterId,
                    final SearchEngineRequestAdapter searchEngineRequestAdapter) {
        if (enabledRewriterIds.contains(rewriterId)) {
            sink.log(message, rewriterId, searchEngineRequestAdapter);
        }
    }

    @Override
    public void endOfRequest(final SearchEngineRequestAdapter searchEngineRequestAdapter) {
        sink.endOfRequest(searchEngineRequestAdapter);
    }

    @Override
    public boolean isLoggingEnabledForRewriter(final String rewriterId) {
        return enabledRewriterIds.contains(rewriterId);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy