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

org.slf4j.simpl.SimpleServiceProvider Maven / Gradle / Ivy

There is a newer version: 7.0.3
Show newest version
/*
 * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.slf4j.simpl;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.kohsuke.MetaInfServices;
import org.opendaylight.infrautils.testutils.internal.LogCaptureRuleLoggerFactory;
import org.slf4j.ILoggerFactory;
import org.slf4j.IMarkerFactory;
import org.slf4j.helpers.BasicMarkerFactory;
import org.slf4j.helpers.NOPMDCAdapter;
import org.slf4j.spi.MDCAdapter;
import org.slf4j.spi.SLF4JServiceProvider;

// Implementation copy/pasted from the class with the same name in slf4j-simple
// but org.slf4j.simple.SimpleLoggerFactory replaced by LogCaptureRuleLoggerFactory
@MetaInfServices
public class SimpleServiceProvider implements SLF4JServiceProvider {

    /**
     * Declare the version of the SLF4J API this implementation is compiled against.
     * The value of this field is modified with each major release.
     */
    // to avoid constant folding by the compiler, this field must *not* be final
    @SuppressWarnings("ConstantField")
    @SuppressFBWarnings("MS_SHOULD_BE_FINAL")
    public static String REQUESTED_API_VERSION = "2.0.99"; // !final

    private ILoggerFactory loggerFactory;
    private IMarkerFactory markerFactory;
    private MDCAdapter mdcAdapter;

    @Override
    public ILoggerFactory getLoggerFactory() {
        return loggerFactory;
    }

    @Override
    public IMarkerFactory getMarkerFactory() {
        return markerFactory;
    }

    @Override
    public MDCAdapter getMDCAdapter() {
        return mdcAdapter;
    }

    @Override
    public String getRequestedApiVersion() {
        return REQUESTED_API_VERSION;
    }

    @Override
    public void initialize() {

        loggerFactory = new LogCaptureRuleLoggerFactory();
        markerFactory = new BasicMarkerFactory();
        mdcAdapter = new NOPMDCAdapter();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy