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

org.slf4j.spi.NOPLoggingEventBuilder Maven / Gradle / Ivy

package org.slf4j.spi;

import java.util.function.Supplier;

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

/**
 * 

A no-operation implementation of {@link LoggingEventBuilder}.

*

*

As the name indicates, the methods in this class do nothing. In case a return value is expected, a singleton, * i.e. the unique instance of this class, is returned. *

*

Note that the default implementations of {@link Logger#atTrace()}, {@link Logger#atDebug()} , {@link Logger#atInfo()}, * {@link Logger#atWarn()} and {@link Logger#atError()}, return an instance of {@link NOPLoggingEventBuilder} * when the relevant level is disabled for current logger. This is the core optimization in the SLF4J fluent API.

* * @author Ceki Gülcü * @since 2.0.0 * */ public class NOPLoggingEventBuilder implements LoggingEventBuilder { static final NOPLoggingEventBuilder SINGLETON = new NOPLoggingEventBuilder(); private NOPLoggingEventBuilder() { } /** *

Returns the singleton instance of this class. * Used by {@link org.slf4j.Logger#makeLoggingEventBuilder(Level) makeLoggingEventBuilder(Level)}.

* * @return the singleton instance of this class */ public static LoggingEventBuilder singleton() { return SINGLETON; } /** *

NOP implementation that does nothing.

* * @param marker a Marker instance to add. * @return */ @Override public LoggingEventBuilder addMarker(Marker marker) { return this; } /** *

NOP implementation that does nothing.

* * @param p * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ @Override public LoggingEventBuilder addArgument(Object p) { return this; } /** *

NOP implementation that does nothing and thus skips calling get() call on the object supplier.

* * @param objectSupplier * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ @Override public LoggingEventBuilder addArgument(Supplier objectSupplier) { return this; } /** *

NOP implementation that does nothing and thus skips calling get() call on the object supplier.

* * @param objectSupplier * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ @Override public LoggingEventBuilder arg(Supplier objectSupplier) { return this; } /** *

NOP implementation that does nothing and thus skips the type cast.

* * @param b a value of type boolean value to add. * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ public LoggingEventBuilder arg(boolean b) { return this; } /** *

NOP implementation that does nothing and thus skips the type cast.

* * @param c a value of type char value to add. * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ @Override public LoggingEventBuilder arg(char c) { return this; } /** *

NOP implementation that does nothing and thus skips the type cast.

* * @param b a value of type byte value to add. * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ @Override public LoggingEventBuilder arg(byte b) { return this; } /** *

NOP implementation that does nothing and thus skips the type cast.

* * @param s a value of type short value to add. * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ public LoggingEventBuilder arg(short s) { return this; } /** *

NOP implementation that does nothing and thus skips the type cast.

* * @param i a value of type int value to add. * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ @Override public LoggingEventBuilder arg(int i) { return this; } /** *

NOP implementation that does nothing and thus skips the type cast.

* * @param l a value of type long value to add. * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ @Override public LoggingEventBuilder arg(long l) { return this; } /** *

NOP implementation that does nothing and thus skips the type cast.

* * @param f a value of type float value to add. * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ @Override public LoggingEventBuilder arg(float f) { return this; } /** *

NOP implementation that does nothing and thus skips the type cast.

* * @param d a value of type float value to add. * @return a LoggingEventBuilder, usually this. * @since 2.1.0 */ @Override public LoggingEventBuilder arg(double d) { return this; } /** * NOP implementation that does nothing. * * @param key the key of the key value pair. * @param value the value of the key value pair. * @return a LoggingEventBuilder, usually this. */ @Override public LoggingEventBuilder addKeyValue(String key, Object value) { return this; } /** * NOP implementation that doesnothing. * * @param key the key of the key value pair. * @param value the value of the key value pair. * @return a LoggingEventBuilder, usually this. */ @Override public LoggingEventBuilder kv(String key, Object value) { return this; } /** * NOP implementation that doesnothing. * * @param key the key of the key value pair. * @param value a supplier of a value for the key value pair. * @return a LoggingEventBuilder, usually this. */ @Override public LoggingEventBuilder addKeyValue(String key, Supplier value) { return this; } /** * NOP implementation that doesnothing. * * @param key the key of the key value pair. * @param value a supplier of a value for the key value pair. * @return a LoggingEventBuilder, usually this. */ @Override public LoggingEventBuilder kv(String key, Supplier value) { return this; } /** * NOP implementation that does nothing. * * @param key the key of the key value pair. * @param b the value of type boolean of the key value pair. * @return a LoggingEventBuilder, usually this. */ @Override public LoggingEventBuilder kv(String key, boolean b) { return this; } /** * NOP implementation that does nothing. * * @param key the key of the key value pair. * @param c the value of type char of the key value pair. * @return */ @Override public LoggingEventBuilder kv(String key, char c) { return this; } /** * NOP implementation that does nothing. * * @param key the key of the key value pair. * @param b the value of type byte of the key value pair. * @return */ @Override public LoggingEventBuilder kv(String key, byte b) { return this; } /** * NOP implementation that does nothing. * * @param key the key of the key value pair. * @param s the value of type short of the key value pair. * @return */ @Override public LoggingEventBuilder kv(String key, short s) { return this; } /** * NOP implementation that does nothing. * * @param key the key of the key value pair. * @param i the value of type int of the key value pair. * @return */ @Override public LoggingEventBuilder kv(String key, int i) { return this; } /** * NOP implementation that does nothing. * * @param key the key of the key value pair. * @param l the value of type long of the key value pair. * @return */ @Override public LoggingEventBuilder kv(String key, long l) { return this; } /** * NOP implementation that does nothing. * * @param key the key of the key value pair. * @param f the value of type float of the key value pair. * @return */ @Override public LoggingEventBuilder kv(String key, float f) { return this; } /** * NOP implementation that does nothing. * * @param key the key of the key value pair. * @param d the value of type double of the key value pair. * @return */ @Override public LoggingEventBuilder kv(String key, double d) { return this; } /** * NOP implementation that does nothing. * * @param cause a throwable * @return */ @Override public LoggingEventBuilder setCause(Throwable cause) { return this; } /** * */ @Override public void log() { } /** * NOP implementation that does nothing. * * @param message the message of the event * @return */ @Override public LoggingEventBuilder setMessage(String message) { return this; } /** * NOP implementation that does nothing. * * @param messageSupplier supplies a String to be used as the message for the event * @return */ @Override public LoggingEventBuilder setMessage(Supplier messageSupplier) { return this; } /** * NOP implementation that does nothing. * * @param message the message to log */ @Override public void log(String message) { } /** * NOP implementation that does nothing. * * @param messageSupplier a Supplier returning a message of type String */ @Override public void log(Supplier messageSupplier) { } /** * NOP implementation that does nothing. * * @param message the message to log * @param arg an argument to be used with the message to log */ @Override public void log(String message, Object arg) { } /** * NOP implementation that does nothing. * * @param message the message to log * @param arg0 first argument to be used with the message to log * @param arg1 second argument to be used with the message to log */ @Override public void log(String message, Object arg0, Object arg1) { } /** * NOP implementation that does nothing. * * @param message the message to log * @param args a list (actually an array) of arguments to be used with the message to log */ @Override public void log(String message, Object... args) { } }