public class DefaultLoggingEventBuilder extends Object implements LoggingEventBuilder, CallerBoundaryAware
LoggingEventBuilder
Modifier and Type | Field and Description |
---|---|
protected Logger |
logger |
protected DefaultLoggingEvent |
loggingEvent |
Constructor and Description |
---|
DefaultLoggingEventBuilder(Logger logger,
Level level) |
Modifier and Type | Method and Description |
---|---|
LoggingEventBuilder |
addArgument(Object p)
Add an argument to the event being built.
|
LoggingEventBuilder |
addArgument(Supplier<?> objectSupplier)
Add an argument supplier to the event being built.
|
LoggingEventBuilder |
addKeyValue(String key,
Object value)
Add a
key value pair to the event being built. |
LoggingEventBuilder |
addKeyValue(String key,
Supplier<Object> value)
Add a
key value pair to the event being built. |
LoggingEventBuilder |
addMarker(Marker marker)
Add a marker to the current logging event being built.
|
void |
log()
After the logging event is built, performs actual logging.
|
protected void |
log(LoggingEvent aLoggingEvent) |
void |
log(String message)
Equivalent to calling
LoggingEventBuilder.setMessage(String) followed by LoggingEventBuilder.log() ; |
void |
log(String message,
Object... args)
Equivalent to calling
LoggingEventBuilder.setMessage(String) followed by zero or more calls to
LoggingEventBuilder.addArgument(Object) (depending on the size of args array) and then LoggingEventBuilder.log() |
void |
log(String message,
Object arg)
Equivalent to calling
LoggingEventBuilder.setMessage(String) followed by LoggingEventBuilder.addArgument(Object) }
and then LoggingEventBuilder.log() |
void |
log(String message,
Object arg0,
Object arg1)
Equivalent to calling
LoggingEventBuilder.setMessage(String) followed by two calls to
LoggingEventBuilder.addArgument(Object) and then LoggingEventBuilder.log() |
void |
log(Supplier<String> messageSupplier)
Equivalent to calling
LoggingEventBuilder.setMessage(Supplier) followed by LoggingEventBuilder.log() |
void |
setCallerBoundary(String fqcn)
Add a fqcn (fully qualified class name) to this event, presumed to be the caller boundary.
|
LoggingEventBuilder |
setCause(Throwable t)
Set the cause for the logging event being built.
|
LoggingEventBuilder |
setMessage(String message)
Sets the message of the logging event.
|
LoggingEventBuilder |
setMessage(Supplier<String> messageSupplier)
Sets the message of the event via a message supplier.
|
protected DefaultLoggingEvent loggingEvent
public DefaultLoggingEventBuilder(Logger logger, Level level)
public LoggingEventBuilder addMarker(Marker marker)
addMarker
in interface LoggingEventBuilder
marker
- the marker to addpublic LoggingEventBuilder setCause(Throwable t)
LoggingEventBuilder
setCause
in interface LoggingEventBuilder
t
- a throwablepublic LoggingEventBuilder addArgument(Object p)
LoggingEventBuilder
addArgument
in interface LoggingEventBuilder
p
- an Object to add.public LoggingEventBuilder addArgument(Supplier<?> objectSupplier)
LoggingEventBuilder
addArgument
in interface LoggingEventBuilder
objectSupplier
- an Object supplier to add.public void setCallerBoundary(String fqcn)
CallerBoundaryAware
setCallerBoundary
in interface CallerBoundaryAware
public void log()
LoggingEventBuilder
LoggingEventBuilder.log()
is omitted, a LoggingEvent
will be built but no logging will occur.log
in interface LoggingEventBuilder
public LoggingEventBuilder setMessage(String message)
LoggingEventBuilder
setMessage
in interface LoggingEventBuilder
public LoggingEventBuilder setMessage(Supplier<String> messageSupplier)
LoggingEventBuilder
setMessage
in interface LoggingEventBuilder
messageSupplier
- supplies a String to be used as the message for the eventpublic void log(String message)
LoggingEventBuilder
LoggingEventBuilder.setMessage(String)
followed by LoggingEventBuilder.log()
;log
in interface LoggingEventBuilder
message
- the message to logpublic void log(String message, Object arg)
LoggingEventBuilder
LoggingEventBuilder.setMessage(String)
followed by LoggingEventBuilder.addArgument(Object)
}
and then LoggingEventBuilder.log()
log
in interface LoggingEventBuilder
message
- the message to logarg
- an argument to be used with the message to logpublic void log(String message, Object arg0, Object arg1)
LoggingEventBuilder
LoggingEventBuilder.setMessage(String)
followed by two calls to
LoggingEventBuilder.addArgument(Object)
and then LoggingEventBuilder.log()
log
in interface LoggingEventBuilder
message
- the message to logarg0
- first argument to be used with the message to logarg1
- second argument to be used with the message to logpublic void log(String message, Object... args)
LoggingEventBuilder
LoggingEventBuilder.setMessage(String)
followed by zero or more calls to
LoggingEventBuilder.addArgument(Object)
(depending on the size of args array) and then LoggingEventBuilder.log()
log
in interface LoggingEventBuilder
message
- the message to logargs
- a list (actually an array) of arguments to be used with the message to logpublic void log(Supplier<String> messageSupplier)
LoggingEventBuilder
LoggingEventBuilder.setMessage(Supplier)
followed by LoggingEventBuilder.log()
log
in interface LoggingEventBuilder
messageSupplier
- a Supplier returning a message of type Stringprotected void log(LoggingEvent aLoggingEvent)
public LoggingEventBuilder addKeyValue(String key, Object value)
LoggingEventBuilder
key value pair
to the event being built.addKeyValue
in interface LoggingEventBuilder
key
- the key of the key value pair.value
- the value of the key value pair.public LoggingEventBuilder addKeyValue(String key, Supplier<Object> value)
LoggingEventBuilder
key value pair
to the event being built.addKeyValue
in interface LoggingEventBuilder
key
- the key of the key value pair.value
- a supplier of a value for the key value pair.Copyright © 2005–2022 QOS.ch. All rights reserved.