// 
// Decompiled by Procyon v0.6.0
// 

package com.google.common.flogger.backend.system;

import com.google.common.flogger.backend.LoggerBackend;
import com.google.common.flogger.backend.NoOpContextDataProvider;
import com.google.common.flogger.util.StaticMethodCaller;
import com.google.common.flogger.context.ContextDataProvider;
import com.google.common.flogger.backend.Platform;

public class DefaultPlatform extends Platform
{
    private static final String BACKEND_FACTORY = "flogger.backend_factory";
    private static final String LOGGING_CONTEXT = "flogger.logging_context";
    private static final String CLOCK = "flogger.clock";
    private final BackendFactory backendFactory;
    private final ContextDataProvider context;
    private final Clock clock;
    private final LogCallerFinder callerFinder;
    
    public DefaultPlatform() {
        final BackendFactory factory = StaticMethodCaller.callGetterFromSystemProperty("flogger.backend_factory", BackendFactory.class);
        this.backendFactory = ((factory != null) ? factory : SimpleBackendFactory.getInstance());
        final ContextDataProvider context = StaticMethodCaller.callGetterFromSystemProperty("flogger.logging_context", ContextDataProvider.class);
        this.context = ((context != null) ? context : NoOpContextDataProvider.getInstance());
        final Clock clock = StaticMethodCaller.callGetterFromSystemProperty("flogger.clock", Clock.class);
        this.clock = ((clock != null) ? clock : SystemClock.getInstance());
        this.callerFinder = StackBasedCallerFinder.getInstance();
    }
    
    DefaultPlatform(final BackendFactory factory, final ContextDataProvider context, final Clock clock, final LogCallerFinder callerFinder) {
        this.backendFactory = factory;
        this.context = context;
        this.clock = clock;
        this.callerFinder = callerFinder;
    }
    
    @Override
    protected LogCallerFinder getCallerFinderImpl() {
        return this.callerFinder;
    }
    
    @Override
    protected LoggerBackend getBackendImpl(final String className) {
        return this.backendFactory.create(className);
    }
    
    @Override
    protected ContextDataProvider getContextDataProviderImpl() {
        return this.context;
    }
    
    @Override
    protected long getCurrentTimeNanosImpl() {
        return this.clock.getCurrentTimeNanos();
    }
    
    @Override
    protected String getConfigInfoImpl() {
        return "Platform: " + this.getClass().getName() + "\nBackendFactory: " + this.backendFactory + "\nClock: " + this.clock + "\nLoggingContext: " + this.context + "\nLogCallerFinder: " + this.callerFinder + "\n";
    }
}
