java.lang.Object
org.slf4j.spi.DefaultLoggingEventBuilder
- All Implemented Interfaces:
CallerBoundaryAware,LoggingEventBuilder
public class DefaultLoggingEventBuilder
extends Object
implements LoggingEventBuilder, CallerBoundaryAware
Default implementation of
LoggingEventBuilder.
It is assumed that when
- Since:
- 2.0.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd an argument to the event being built.addArgument(Supplier<?> objectSupplier) Add an argument supplier to the event being built.addKeyValue(String key, Object value) Add akey value pairto the event being built.addKeyValue(String key, Supplier<Object> value) Add akey value pairto the event being built.Add a marker to the current logging event being built.voidlog()After the logging event is built, performs actual logging.voidEquivalent to callingLoggingEventBuilder.setMessage(String)followed byLoggingEventBuilder.log();voidEquivalent to callingLoggingEventBuilder.setMessage(String)followed byLoggingEventBuilder.addArgument(Object)} and thenLoggingEventBuilder.log()voidEquivalent to callingLoggingEventBuilder.setMessage(String)followed by zero or more calls toLoggingEventBuilder.addArgument(Object)(depending on the size of args array) and thenLoggingEventBuilder.log()voidEquivalent to callingLoggingEventBuilder.setMessage(String)followed by two calls toLoggingEventBuilder.addArgument(Object)and thenLoggingEventBuilder.log()voidEquivalent to callingLoggingEventBuilder.setMessage(Supplier)followed byLoggingEventBuilder.log()protected voidlog(LoggingEvent aLoggingEvent) voidsetCallerBoundary(String fqcn) Add a fqcn (fully qualified class name) to this event, presumed to be the caller boundary.Set the cause for the logging event being built.setMessage(String message) Sets the message of the logging event.setMessage(Supplier<String> messageSupplier) Sets the message of the event via a message supplier.
-
Field Details
-
loggingEvent
-
logger
-
-
Constructor Details
-
DefaultLoggingEventBuilder
-
-
Method Details
-
addMarker
Add a marker to the current logging event being built. It is possible to add multiple markers to the same logging event.- Specified by:
addMarkerin interfaceLoggingEventBuilder- Parameters:
marker- the marker to add- Returns:
- a LoggingEventBuilder instance, usually this.
-
setCause
Description copied from interface:LoggingEventBuilderSet the cause for the logging event being built.- Specified by:
setCausein interfaceLoggingEventBuilder- Parameters:
t- a throwable- Returns:
- a LoggingEventBuilder instance, usually this.
-
addArgument
Description copied from interface:LoggingEventBuilderAdd an argument to the event being built. Synonymous withLoggingEventBuilder.arg(Object)method.- Specified by:
addArgumentin interfaceLoggingEventBuilder- Parameters:
p- an Object to add.- Returns:
- a LoggingEventBuilder instance, usually this.
-
addArgument
Description copied from interface:LoggingEventBuilderAdd an argument supplier to the event being built. Synonymous with
LoggingEventBuilder.arg(Supplier)method.- Specified by:
addArgumentin interfaceLoggingEventBuilder- Parameters:
objectSupplier- an Object supplier to add.- Returns:
- a LoggingEventBuilder instance, usually this.
-
setCallerBoundary
Description copied from interface:CallerBoundaryAwareAdd a fqcn (fully qualified class name) to this event, presumed to be the caller boundary.- Specified by:
setCallerBoundaryin interfaceCallerBoundaryAware- Parameters:
fqcn-
-
log
Description copied from interface:LoggingEventBuilderAfter the logging event is built, performs actual logging. This method must be called for logging to occur. If the call toLoggingEventBuilder.log()is omitted, aLoggingEventwill be built but no logging will occur.- Specified by:
login interfaceLoggingEventBuilder
-
setMessage
Description copied from interface:LoggingEventBuilderSets the message of the logging event.- Specified by:
setMessagein interfaceLoggingEventBuilder- Parameters:
message- the message of the event- Returns:
- a LoggingEventBuilder instance, usually this.
-
setMessage
Description copied from interface:LoggingEventBuilderSets the message of the event via a message supplier.- Specified by:
setMessagein interfaceLoggingEventBuilder- Parameters:
messageSupplier- supplies a String to be used as the message for the event- Returns:
- a LoggingEventBuilder instance, usually this.
-
log
Description copied from interface:LoggingEventBuilderEquivalent to callingLoggingEventBuilder.setMessage(String)followed byLoggingEventBuilder.log();- Specified by:
login interfaceLoggingEventBuilder- Parameters:
message- the message to log
-
log
Description copied from interface:LoggingEventBuilderEquivalent to callingLoggingEventBuilder.setMessage(String)followed byLoggingEventBuilder.addArgument(Object)} and thenLoggingEventBuilder.log()- Specified by:
login interfaceLoggingEventBuilder- Parameters:
message- the message to logarg- an argument to be used with the message to log
-
log
Description copied from interface:LoggingEventBuilderEquivalent to callingLoggingEventBuilder.setMessage(String)followed by two calls toLoggingEventBuilder.addArgument(Object)and thenLoggingEventBuilder.log()- Specified by:
login interfaceLoggingEventBuilder- 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
Description copied from interface:LoggingEventBuilderEquivalent to callingLoggingEventBuilder.setMessage(String)followed by zero or more calls toLoggingEventBuilder.addArgument(Object)(depending on the size of args array) and thenLoggingEventBuilder.log()- Specified by:
login interfaceLoggingEventBuilder- Parameters:
message- the message to logargs- a list (actually an array) of arguments to be used with the message to log
-
log
Description copied from interface:LoggingEventBuilderEquivalent to callingLoggingEventBuilder.setMessage(Supplier)followed byLoggingEventBuilder.log()- Specified by:
login interfaceLoggingEventBuilder- Parameters:
messageSupplier- a Supplier returning a message of type String
-
log
-
addKeyValue
Description copied from interface:LoggingEventBuilderAdd akey value pairto the event being built.- Specified by:
addKeyValuein interfaceLoggingEventBuilder- Parameters:
key- the key of the key value pair.value- the value of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
-
addKeyValue
Description copied from interface:LoggingEventBuilderAdd akey value pairto the event being built.- Specified by:
addKeyValuein interfaceLoggingEventBuilder- Parameters:
key- the key of the key value pair.value- a supplier of a value for the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
-