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

io.github.naviud.logtracker.actions.trackerproviders.TrackerIdProvider Maven / Gradle / Ivy

Go to download

LogTracker is a logger module done for Play framework which prepends a unique UUID(tracker id) for the log messages that are generated for a particular request. Tracker id can be passed from a HTTP header or will be selected randomly when a request is initiated.

There is a newer version: 1.1.3
Show newest version
package io.github.naviud.logtracker.actions.trackerproviders;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;

public class TrackerIdProvider implements Provider {

    private TrackerIdFetcher uuidBasedTrackerIdFetcher;
    private TrackerIdFetcher headerBasedTrackerIdFetcher;

    @Inject
    public TrackerIdProvider(@Named("UUIDBasedTrackerIdProvider") TrackerIdFetcher uuidBasedTrackerIdFetcher,
                             @Named("HeaderBasedTrackerIdFetcher") TrackerIdFetcher headerBasedTrackerIdFetcher) {
        this.uuidBasedTrackerIdFetcher = uuidBasedTrackerIdFetcher;
        this.headerBasedTrackerIdFetcher = headerBasedTrackerIdFetcher;
    }

    @Override
    public TrackerIdFetcher get() {
        headerBasedTrackerIdFetcher.setNextProvider(uuidBasedTrackerIdFetcher);
        uuidBasedTrackerIdFetcher.setNextProvider(null);

        return headerBasedTrackerIdFetcher;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy