SLF4J API Source Code

SLF4J API is a simple API that allows to plug in any desired logging library at deployment time.

Here is the source code for SLF4J API 2.0.4. You can download its pre-compiled version slf4j-api-2.0.4.jar at SLF4J Download Website.

✍: FYIcenter.com

org/slf4j/spi/NOPLoggingEventBuilder.java

package org.slf4j.spi;

import java.util.function.Supplier;

import org.slf4j.Marker;
import org.slf4j.event.Level;

/**
 * <p>A no-operation implementation of {@link LoggingEventBuilder}.</p>
 *
 * <p>As the name indicates, the method in this class do nothing, except when a return value is expected
 * in which case a singleton, i.e. the unique instance of this class is returned.
 * </p
 *
 * @author Ceki G&uuml;lc&uuml;
 * @since 2.0.0
 *
 */
public class NOPLoggingEventBuilder implements LoggingEventBuilder {

    static final NOPLoggingEventBuilder SINGLETON = new NOPLoggingEventBuilder();

    private NOPLoggingEventBuilder() {
    }

    /**
     * <p>Returns the singleton instance of this class.
     * Used by {@link org.slf4j.Logger#makeLoggingEventBuilder(Level) makeLoggingEventBuilder(Level)}.</p>
     *
     * @return the singleton instance of this class
     */
    public static LoggingEventBuilder singleton() {
        return SINGLETON;
    }

    @Override
    public LoggingEventBuilder addMarker(Marker marker) {
        return singleton();
    }

    @Override
    public LoggingEventBuilder addArgument(Object p) {
        return singleton();
    }

    @Override
    public LoggingEventBuilder addArgument(Supplier<?> objectSupplier) {
        return singleton();
    }

    @Override
    public LoggingEventBuilder addKeyValue(String key, Object value) {
        return singleton();
    }

    @Override
    public LoggingEventBuilder addKeyValue(String key, Supplier<Object> value) {
        return singleton();
    }

    @Override
    public LoggingEventBuilder setCause(Throwable cause) {
        return singleton();
    }

    @Override
    public void log() {
    }

    @Override
    public LoggingEventBuilder setMessage(String message) {
        return this;
    }
    @Override
    public LoggingEventBuilder setMessage(Supplier<String> messageSupplier) {
        return this;
    }

    @Override
    public void log(String message) {
    }

    @Override
    public void log(Supplier<String> messageSupplier) {
    }

    @Override
    public void log(String message, Object arg) {
    }

    @Override
    public void log(String message, Object arg0, Object arg1) {
    }

    @Override
    public void log(String message, Object... args) {

    }

}

org/slf4j/spi/NOPLoggingEventBuilder.java

 

Or download all of them as a single archive file:

File name: slf4j-api-2.0.4-sources.jar
File size: 70304 bytes
Release date: 2022-11-17
Download 

 

Source Code for SLF4J Simple Logging

Downloading SLF4J Components

Downloading and Reviewing SLF4J Packages

⇑⇑ SLF4J - Simple Logging Facade for Java

2020-02-13, 26781👍, 2💬