Package org.slf4j.spi
Interface LoggingEventBuilder
-
- All Known Implementing Classes:
DefaultLoggingEventBuilder,NOPLoggingEventBuilder
public interface LoggingEventBuilder
This is the main interface in slf4j's fluent API for creatinglogging events.- Since:
- 2.0.0
- Author:
- Ceki Gülcü
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description LoggingEventBuilderaddArgument(java.lang.Object p)Add an argument to the event being built.LoggingEventBuilderaddArgument(java.util.function.Supplier<?> objectSupplier)Add an argument supplier to the event being built.LoggingEventBuilderaddKeyValue(java.lang.String key, java.lang.Object value)Add akey value pairto the event being built.LoggingEventBuilderaddKeyValue(java.lang.String key, java.util.function.Supplier<java.lang.Object> valueSupplier)Add akey value pairto the event being built.LoggingEventBuilderaddMarker(Marker marker)Amarkerto the event being built.voidlog()After the logging event is built, performs actual logging.voidlog(java.lang.String message)Equivalent to callingsetMessage(String)followed bylog();voidlog(java.lang.String message, java.lang.Object arg)voidlog(java.lang.String message, java.lang.Object... args)Equivalent to callingsetMessage(String)followed by zero or more calls toaddArgument(Object)(depending on the size of args array) and thenlog()voidlog(java.lang.String message, java.lang.Object arg0, java.lang.Object arg1)Equivalent to callingsetMessage(String)followed by two calls toaddArgument(Object)and thenlog()voidlog(java.util.function.Supplier<java.lang.String> messageSupplier)Equivalent to callingsetMessage(Supplier)followed bylog()LoggingEventBuildersetCause(java.lang.Throwable cause)Set the cause for the logging event being built.LoggingEventBuildersetMessage(java.lang.String message)Sets the message of the logging event.LoggingEventBuildersetMessage(java.util.function.Supplier<java.lang.String> messageSupplier)Sets the message of the event via a message supplier.
-
-
-
Method Detail
-
setCause
@CheckReturnValue LoggingEventBuilder setCause(java.lang.Throwable cause)
Set the cause for the logging event being built.- Parameters:
cause- a throwable- Returns:
- a LoggingEventBuilder, usually this.
-
addMarker
@CheckReturnValue LoggingEventBuilder addMarker(Marker marker)
Amarkerto the event being built.- Parameters:
marker- a Marker instance to add.- Returns:
- a LoggingEventBuilder, usually this.
-
addArgument
@CheckReturnValue LoggingEventBuilder addArgument(java.lang.Object p)
Add an argument to the event being built.- Parameters:
p- an Object to add.- Returns:
- a LoggingEventBuilder, usually this.
-
addArgument
@CheckReturnValue LoggingEventBuilder addArgument(java.util.function.Supplier<?> objectSupplier)
Add an argument supplier to the event being built.- Parameters:
objectSupplier- an Object supplier to add.- Returns:
- a LoggingEventBuilder, usually this.
-
addKeyValue
@CheckReturnValue LoggingEventBuilder addKeyValue(java.lang.String key, java.lang.Object value)
Add akey value pairto the event being built.- Parameters:
key- the key of the key value pair.value- the value of the key value pair.- Returns:
- a LoggingEventBuilder, usually this.
-
addKeyValue
@CheckReturnValue LoggingEventBuilder addKeyValue(java.lang.String key, java.util.function.Supplier<java.lang.Object> valueSupplier)
Add akey value pairto the event being built.- Parameters:
key- the key of the key value pair.valueSupplier- a supplier of a value for the key value pair.- Returns:
- a LoggingEventBuilder, usually this.
-
setMessage
@CheckReturnValue LoggingEventBuilder setMessage(java.lang.String message)
Sets the message of the logging event.- Since:
- 2.0.0-beta0
-
setMessage
@CheckReturnValue LoggingEventBuilder setMessage(java.util.function.Supplier<java.lang.String> messageSupplier)
Sets the message of the event via a message supplier.- Parameters:
messageSupplier- supplies a String to be used as the message for the event- Since:
- 2.0.0-beta0
-
log
void log()
After the logging event is built, performs actual logging. This method must be called for logging to occur. If the call tolog()is omitted, aLoggingEventwill be built but no logging will occur.- Since:
- 2.0.0-beta0
-
log
void log(java.lang.String message)
Equivalent to callingsetMessage(String)followed bylog();- Parameters:
message- the message to log
-
log
void log(java.lang.String message, java.lang.Object arg)
- Parameters:
message- the message to logarg- an argument to be used with the message to log
-
log
void log(java.lang.String message, java.lang.Object arg0, java.lang.Object arg1)
Equivalent to callingsetMessage(String)followed by two calls toaddArgument(Object)and thenlog()- Parameters:
message- the message to logarg0- first argument to be used with the message to logarg1- second argument to be used with the message to log
-
log
void log(java.lang.String message, java.lang.Object... args)
Equivalent to callingsetMessage(String)followed by zero or more calls toaddArgument(Object)(depending on the size of args array) and thenlog()- Parameters:
message- the message to logargs- a list (actually an array) of arguments to be used with the message to log
-
log
void log(java.util.function.Supplier<java.lang.String> messageSupplier)
Equivalent to callingsetMessage(Supplier)followed bylog()- Parameters:
messageSupplier- a Supplier returning a message of type String
-
-