Package org.slf4j.spi
Class DefaultLoggingEventBuilder
java.lang.Object
org.slf4j.spi.DefaultLoggingEventBuilder
- All Implemented Interfaces:
CallerBoundaryAware
,LoggingEventBuilder
public class DefaultLoggingEventBuilder
extends Object
implements LoggingEventBuilder, CallerBoundaryAware
Default implementation of
LoggingEventBuilder
-
Field Summary
-
Constructor Summary
-
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 pair
to the event being built.addKeyValue
(String key, Supplier<Object> value) Add akey value pair
to the event being built.Add a marker to the current logging event being built.void
log()
After the logging event is built, performs actual logging.void
Equivalent to callingLoggingEventBuilder.setMessage(String)
followed byLoggingEventBuilder.log()
;void
Equivalent to callingLoggingEventBuilder.setMessage(String)
followed byLoggingEventBuilder.addArgument(Object)
} and thenLoggingEventBuilder.log()
void
Equivalent to callingLoggingEventBuilder.setMessage(String)
followed by zero or more calls toLoggingEventBuilder.addArgument(Object)
(depending on the size of args array) and thenLoggingEventBuilder.log()
void
Equivalent to callingLoggingEventBuilder.setMessage(String)
followed by two calls toLoggingEventBuilder.addArgument(Object)
and thenLoggingEventBuilder.log()
void
Equivalent to callingLoggingEventBuilder.setMessage(Supplier)
followed byLoggingEventBuilder.log()
protected void
log
(LoggingEvent aLoggingEvent) void
setCallerBoundary
(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:
addMarker
in interfaceLoggingEventBuilder
- Parameters:
marker
- the marker to add- Returns:
- a LoggingEventBuilder, usually this.
-
setCause
Description copied from interface:LoggingEventBuilder
Set the cause for the logging event being built.- Specified by:
setCause
in interfaceLoggingEventBuilder
- Parameters:
t
- a throwable- Returns:
- a LoggingEventBuilder, usually this.
-
addArgument
Description copied from interface:LoggingEventBuilder
Add an argument to the event being built.- Specified by:
addArgument
in interfaceLoggingEventBuilder
- Parameters:
p
- an Object to add.- Returns:
- a LoggingEventBuilder, usually this.
-
addArgument
Description copied from interface:LoggingEventBuilder
Add an argument supplier to the event being built.- Specified by:
addArgument
in interfaceLoggingEventBuilder
- Parameters:
objectSupplier
- an Object supplier to add.- Returns:
- a LoggingEventBuilder, usually this.
-
addKeyValue
Description copied from interface:LoggingEventBuilder
Add akey value pair
to the event being built.- Specified by:
addKeyValue
in interfaceLoggingEventBuilder
- Parameters:
key
- the key of the key value pair.value
- the value of the key value pair.- Returns:
- a LoggingEventBuilder, usually this.
-
addKeyValue
Description copied from interface:LoggingEventBuilder
Add akey value pair
to the event being built.- Specified by:
addKeyValue
in interfaceLoggingEventBuilder
- 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.
-
setCallerBoundary
Description copied from interface:CallerBoundaryAware
Add a fqcn (fully qualified class name) to this event, presumed to be the caller boundary.- Specified by:
setCallerBoundary
in interfaceCallerBoundaryAware
- Parameters:
fqcn
-
-
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 toLoggingEventBuilder.log()
is omitted, aLoggingEvent
will be built but no logging will occur.- Specified by:
log
in interfaceLoggingEventBuilder
-
setMessage
Description copied from interface:LoggingEventBuilder
Sets the message of the logging event.- Specified by:
setMessage
in interfaceLoggingEventBuilder
-
setMessage
Description copied from interface:LoggingEventBuilder
Sets the message of the event via a message supplier.- Specified by:
setMessage
in interfaceLoggingEventBuilder
- Parameters:
messageSupplier
- supplies a String to be used as the message for the event
-
log
Description copied from interface:LoggingEventBuilder
Equivalent to callingLoggingEventBuilder.setMessage(String)
followed byLoggingEventBuilder.log()
;- Specified by:
log
in interfaceLoggingEventBuilder
- Parameters:
message
- the message to log
-
log
Description copied from interface:LoggingEventBuilder
Equivalent to callingLoggingEventBuilder.setMessage(String)
followed byLoggingEventBuilder.addArgument(Object)
} and thenLoggingEventBuilder.log()
- Specified by:
log
in interfaceLoggingEventBuilder
- Parameters:
message
- the message to logarg
- an argument to be used with the message to log
-
log
Description copied from interface:LoggingEventBuilder
Equivalent to callingLoggingEventBuilder.setMessage(String)
followed by two calls toLoggingEventBuilder.addArgument(Object)
and thenLoggingEventBuilder.log()
- Specified by:
log
in 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:LoggingEventBuilder
Equivalent 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:
log
in 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:LoggingEventBuilder
Equivalent to callingLoggingEventBuilder.setMessage(Supplier)
followed byLoggingEventBuilder.log()
- Specified by:
log
in interfaceLoggingEventBuilder
- Parameters:
messageSupplier
- a Supplier returning a message of type String
-
log
-