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
.
It is assumed that when
- Since:
- 2.0.0
-
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 instance, 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 instance, usually this.
-
addArgument
Description copied from interface:LoggingEventBuilder
Add an argument to the event being built. Synonymous withLoggingEventBuilder.arg(Object)
method.- Specified by:
addArgument
in interfaceLoggingEventBuilder
- Parameters:
p
- an Object to add.- Returns:
- a LoggingEventBuilder instance, usually this.
-
addArgument
Description copied from interface:LoggingEventBuilder
Add an argument supplier to the event being built. Synonymous with
LoggingEventBuilder.arg(Supplier)
method.- Specified by:
addArgument
in interfaceLoggingEventBuilder
- Parameters:
objectSupplier
- an Object supplier to add.- Returns:
- a LoggingEventBuilder instance, 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
- Parameters:
message
- the message of the event- Returns:
- a LoggingEventBuilder instance, usually this.
-
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- Returns:
- a LoggingEventBuilder instance, usually this.
-
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
-
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 instance, 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 instance, usually this.
-