Package org.slf4j.spi
Class DefaultLoggingEventBuilder
- java.lang.Object
-
- org.slf4j.spi.DefaultLoggingEventBuilder
-
- All Implemented Interfaces:
CallerBoundaryAware,LoggingEventBuilder
public class DefaultLoggingEventBuilder extends java.lang.Object implements LoggingEventBuilder, CallerBoundaryAware
Default implementation ofLoggingEventBuilder
-
-
Field Summary
Fields Modifier and Type Field Description protected Loggerloggerprotected DefaultLoggingEventloggingEvent
-
Constructor Summary
Constructors Constructor Description DefaultLoggingEventBuilder(Logger logger, Level level)
-
Method Summary
All Methods Instance Methods Concrete 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> value)Add akey value pairto the event being built.LoggingEventBuilderaddMarker(Marker marker)Add a marker to the current logging event being built.voidlog()After the logging event is built, performs actual logging.voidlog(java.lang.String message)Equivalent to callingLoggingEventBuilder.setMessage(String)followed byLoggingEventBuilder.log();voidlog(java.lang.String message, java.lang.Object arg)Equivalent to callingLoggingEventBuilder.setMessage(String)followed byLoggingEventBuilder.addArgument(Object)} and thenLoggingEventBuilder.log()voidlog(java.lang.String message, java.lang.Object... args)Equivalent to callingLoggingEventBuilder.setMessage(String)followed by zero or more calls toLoggingEventBuilder.addArgument(Object)(depending on the size of args array) and thenLoggingEventBuilder.log()voidlog(java.lang.String message, java.lang.Object arg0, java.lang.Object arg1)Equivalent to callingLoggingEventBuilder.setMessage(String)followed by two calls toLoggingEventBuilder.addArgument(Object)and thenLoggingEventBuilder.log()voidlog(java.util.function.Supplier<java.lang.String> messageSupplier)Equivalent to callingLoggingEventBuilder.setMessage(Supplier)followed byLoggingEventBuilder.log()protected voidlog(LoggingEvent aLoggingEvent)voidsetCallerBoundary(java.lang.String fqcn)Add a fqcn (fully qualified class name) to this event, presumed to be the caller boundary.LoggingEventBuildersetCause(java.lang.Throwable t)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.
-
-
-
Field Detail
-
loggingEvent
protected DefaultLoggingEvent loggingEvent
-
-
Constructor Detail
-
DefaultLoggingEventBuilder
public DefaultLoggingEventBuilder(Logger logger, Level level)
-
-
Method Detail
-
addMarker
public LoggingEventBuilder addMarker(Marker marker)
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, usually this.
-
setCause
public LoggingEventBuilder setCause(java.lang.Throwable t)
Description copied from interface:LoggingEventBuilderSet the cause for the logging event being built.- Specified by:
setCausein interfaceLoggingEventBuilder- Parameters:
t- a throwable- Returns:
- a LoggingEventBuilder, usually this.
-
addArgument
public LoggingEventBuilder addArgument(java.lang.Object p)
Description copied from interface:LoggingEventBuilderAdd an argument to the event being built.- Specified by:
addArgumentin interfaceLoggingEventBuilder- Parameters:
p- an Object to add.- Returns:
- a LoggingEventBuilder, usually this.
-
addArgument
public LoggingEventBuilder addArgument(java.util.function.Supplier<?> objectSupplier)
Description copied from interface:LoggingEventBuilderAdd an argument supplier to the event being built.- Specified by:
addArgumentin interfaceLoggingEventBuilder- Parameters:
objectSupplier- an Object supplier to add.- Returns:
- a LoggingEventBuilder, usually this.
-
addKeyValue
public LoggingEventBuilder addKeyValue(java.lang.String key, java.lang.Object value)
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, usually this.
-
addKeyValue
public LoggingEventBuilder addKeyValue(java.lang.String key, java.util.function.Supplier<java.lang.Object> value)
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, usually this.
-
setCallerBoundary
public void setCallerBoundary(java.lang.String fqcn)
Description copied from interface:CallerBoundaryAwareAdd a fqcn (fully qualified class name) to this event, presumed to be the caller boundary.- Specified by:
setCallerBoundaryin interfaceCallerBoundaryAware
-
log
public void 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
public LoggingEventBuilder setMessage(java.lang.String message)
Description copied from interface:LoggingEventBuilderSets the message of the logging event.- Specified by:
setMessagein interfaceLoggingEventBuilder
-
setMessage
public LoggingEventBuilder setMessage(java.util.function.Supplier<java.lang.String> messageSupplier)
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
-
log
public void log(java.lang.String message)
Description copied from interface:LoggingEventBuilderEquivalent to callingLoggingEventBuilder.setMessage(String)followed byLoggingEventBuilder.log();- Specified by:
login interfaceLoggingEventBuilder- Parameters:
message- the message to log
-
log
public void log(java.lang.String message, java.lang.Object arg)
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
public void log(java.lang.String message, java.lang.Object arg0, java.lang.Object arg1)
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
public void log(java.lang.String message, java.lang.Object... args)
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
public void log(java.util.function.Supplier<java.lang.String> messageSupplier)
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
protected void log(LoggingEvent aLoggingEvent)
-
-