Package org.slf4j.spi

Class NOPLoggingEventBuilder

java.lang.Object
org.slf4j.spi.NOPLoggingEventBuilder
All Implemented Interfaces:
LoggingEventBuilder

public class NOPLoggingEventBuilder extends Object implements LoggingEventBuilder

A no-operation implementation of 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 Logger.atTrace(), Logger.atDebug() , Logger.atInfo(), Logger.atWarn() and Logger.atError(), return an instance of NOPLoggingEventBuilder when the relevant level is disabled for current logger. This is the core optimization in the SLF4J fluent API.

Since:
2.0.0
Author:
Ceki Gülcü
  • Method Details

    • singleton

      public static LoggingEventBuilder singleton()

      Returns the singleton instance of this class. Used by makeLoggingEventBuilder(Level).

      Returns:
      the singleton instance of this class
    • addMarker

      NOP implementation that does nothing.

      Specified by:
      addMarker in interface LoggingEventBuilder
      Parameters:
      marker - a Marker instance to add.
      Returns:
    • addArgument

      NOP implementation that does nothing.

      Specified by:
      addArgument in interface LoggingEventBuilder
      Parameters:
      p -
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • addArgument

      public LoggingEventBuilder addArgument(Supplier<?> objectSupplier)

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

      Specified by:
      addArgument in interface LoggingEventBuilder
      Parameters:
      objectSupplier -
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • arg

      public LoggingEventBuilder arg(Supplier<?> objectSupplier)

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

      Specified by:
      arg in interface LoggingEventBuilder
      Parameters:
      objectSupplier -
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • arg

      public LoggingEventBuilder arg(boolean b)

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

      Specified by:
      arg in interface LoggingEventBuilder
      Parameters:
      b - a value of type boolean value to add.
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • arg

      public LoggingEventBuilder arg(char c)

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

      Specified by:
      arg in interface LoggingEventBuilder
      Parameters:
      c - a value of type char value to add.
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • arg

      public LoggingEventBuilder arg(byte b)

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

      Specified by:
      arg in interface LoggingEventBuilder
      Parameters:
      b - a value of type byte value to add.
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • arg

      public LoggingEventBuilder arg(short s)

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

      Specified by:
      arg in interface LoggingEventBuilder
      Parameters:
      s - a value of type short value to add.
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • arg

      public LoggingEventBuilder arg(int i)

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

      Specified by:
      arg in interface LoggingEventBuilder
      Parameters:
      i - a value of type int value to add.
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • arg

      public LoggingEventBuilder arg(long l)

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

      Specified by:
      arg in interface LoggingEventBuilder
      Parameters:
      l - a value of type long value to add.
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • arg

      public LoggingEventBuilder arg(float f)

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

      Specified by:
      arg in interface LoggingEventBuilder
      Parameters:
      f - a value of type float value to add.
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • arg

      public LoggingEventBuilder arg(double d)

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

      Specified by:
      arg in interface LoggingEventBuilder
      Parameters:
      d - a value of type float value to add.
      Returns:
      a LoggingEventBuilder, usually this.
      Since:
      2.1.0
    • addKeyValue

      NOP implementation that does nothing.
      Specified by:
      addKeyValue in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      value - the value of the key value pair.
      Returns:
      a LoggingEventBuilder, usually this.
    • kv

      public LoggingEventBuilder kv(String key, Object value)
      NOP implementation that doesnothing.
      Specified by:
      kv in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      value - the value of the key value pair.
      Returns:
      a LoggingEventBuilder, usually this.
    • addKeyValue

      NOP implementation that doesnothing.
      Specified by:
      addKeyValue in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      value - a supplier of a value for the key value pair.
      Returns:
      a LoggingEventBuilder, usually this.
    • kv

      public LoggingEventBuilder kv(String key, Supplier<Object> value)
      NOP implementation that doesnothing.
      Specified by:
      kv in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      value - a supplier of a value for the key value pair.
      Returns:
      a LoggingEventBuilder, usually this.
    • kv

      public LoggingEventBuilder kv(String key, boolean b)
      NOP implementation that does nothing.
      Specified by:
      kv in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      b - the value of type boolean of the key value pair.
      Returns:
      a LoggingEventBuilder, usually this.
    • kv

      public LoggingEventBuilder kv(String key, char c)
      NOP implementation that does nothing.
      Specified by:
      kv in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      c - the value of type char of the key value pair.
      Returns:
    • kv

      public LoggingEventBuilder kv(String key, byte b)
      NOP implementation that does nothing.
      Specified by:
      kv in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      b - the value of type byte of the key value pair.
      Returns:
    • kv

      public LoggingEventBuilder kv(String key, short s)
      NOP implementation that does nothing.
      Specified by:
      kv in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      s - the value of type short of the key value pair.
      Returns:
    • kv

      public LoggingEventBuilder kv(String key, int i)
      NOP implementation that does nothing.
      Specified by:
      kv in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      i - the value of type int of the key value pair.
      Returns:
    • kv

      public LoggingEventBuilder kv(String key, long l)
      NOP implementation that does nothing.
      Specified by:
      kv in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      l - the value of type long of the key value pair.
      Returns:
    • kv

      public LoggingEventBuilder kv(String key, float f)
      NOP implementation that does nothing.
      Specified by:
      kv in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      f - the value of type float of the key value pair.
      Returns:
    • kv

      public LoggingEventBuilder kv(String key, double d)
      NOP implementation that does nothing.
      Specified by:
      kv in interface LoggingEventBuilder
      Parameters:
      key - the key of the key value pair.
      d - the value of type double of the key value pair.
      Returns:
    • setCause

      NOP implementation that does nothing.
      Specified by:
      setCause in interface LoggingEventBuilder
      Parameters:
      cause - a throwable
      Returns:
    • log

      public void log()
      Description copied from interface: LoggingEventBuilder
      After the logging event is built, performs actual logging. This method must be called for logging to occur. If the call to LoggingEventBuilder.log() is omitted, a LoggingEvent will be built but no logging will occur.
      Specified by:
      log in interface LoggingEventBuilder
    • setMessage

      NOP implementation that does nothing.
      Specified by:
      setMessage in interface LoggingEventBuilder
      Parameters:
      message - the message of the event
      Returns:
    • setMessage

      public LoggingEventBuilder setMessage(Supplier<String> messageSupplier)
      NOP implementation that does nothing.
      Specified by:
      setMessage in interface LoggingEventBuilder
      Parameters:
      messageSupplier - supplies a String to be used as the message for the event
      Returns:
    • log

      public void log(String message)
      NOP implementation that does nothing.
      Specified by:
      log in interface LoggingEventBuilder
      Parameters:
      message - the message to log
    • log

      public void log(Supplier<String> messageSupplier)
      NOP implementation that does nothing.
      Specified by:
      log in interface LoggingEventBuilder
      Parameters:
      messageSupplier - a Supplier returning a message of type String
    • log

      public void log(String message, Object arg)
      NOP implementation that does nothing.
      Specified by:
      log in interface LoggingEventBuilder
      Parameters:
      message - the message to log
      arg - an argument to be used with the message to log
    • log

      public void log(String message, Object arg0, Object arg1)
      NOP implementation that does nothing.
      Specified by:
      log in interface LoggingEventBuilder
      Parameters:
      message - the message to log
      arg0 - first argument to be used with the message to log
      arg1 - second argument to be used with the message to log
    • log

      public void log(String message, Object... args)
      NOP implementation that does nothing.
      Specified by:
      log in interface LoggingEventBuilder
      Parameters:
      message - the message to log
      args - a list (actually an array) of arguments to be used with the message to log