Interface LoggingEventBuilder
- All Known Implementing Classes:
DefaultLoggingEventBuilder
,NOPLoggingEventBuilder
logging events
.- Since:
- 2.0.0
- Author:
- Ceki Gülcü
-
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> valueSupplier) Add akey value pair
to the event being built.Amarker
to the event being built.default LoggingEventBuilder
arg
(boolean b) Add a value of typeboolean
to the event being built.default LoggingEventBuilder
arg
(byte b) Add a value of typebyte
to the event being built.default LoggingEventBuilder
arg
(char c) Add a value of typechar
to the event being built.default LoggingEventBuilder
arg
(double d) Add a value of typedouble
to the event being built.default LoggingEventBuilder
arg
(float f) Add a value of typefloat
to the event being built.default LoggingEventBuilder
arg
(int i) Add a value of typeint
to the event being built.default LoggingEventBuilder
arg
(long l) Add a value of typelong
to the event being built.default LoggingEventBuilder
arg
(short s) Add a value of typeshort
to the event being built.default LoggingEventBuilder
Add an argument to the event being built.default LoggingEventBuilder
Add an argument supplier to the event being built.default LoggingEventBuilder
Add akey value pair
to the event being built, with the value part being of typeboolean
.default LoggingEventBuilder
Add akey value pair
to the event being built, with the value part being of typebyte
.default LoggingEventBuilder
Add akey value pair
to the event being built, with the value part being of typechar
.default LoggingEventBuilder
Add akey value pair
to the event being built, with the value part being of typedouble
.default LoggingEventBuilder
Add akey value pair
to the event being built, with the value part being of typefloat
.default LoggingEventBuilder
Add akey value pair
to the event being built, with the value part being of typeint
.default LoggingEventBuilder
Add akey value pair
to the event being built, with the value part being of typelong
.default LoggingEventBuilder
Add akey value pair
to the event being built, with the value part being of typeshort
.default LoggingEventBuilder
Add akey value pair
to the event being built.default LoggingEventBuilder
Add akey value pair
to the event being built.void
log()
After the logging event is built, performs actual logging.void
Equivalent to callingsetMessage(String)
followed bylog()
;void
void
Equivalent to callingsetMessage(String)
followed by zero or more calls toaddArgument(Object)
(depending on the size of args array) and thenlog()
void
Equivalent to callingsetMessage(String)
followed by two calls toaddArgument(Object)
and thenlog()
void
Equivalent to callingsetMessage(Supplier)
followed bylog()
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.
-
Method Details
-
setCause
Set the cause for the logging event being built.- Parameters:
cause
- a throwable- Returns:
- a LoggingEventBuilder instance, usually this.
-
addMarker
Amarker
to the event being built.- Parameters:
marker
- a Marker instance to add.- Returns:
- a LoggingEventBuilder instance, usually this.
-
addArgument
Add an argument to the event being built. Synonymous witharg(Object)
method.- Parameters:
p
- an Object to add.- Returns:
- a LoggingEventBuilder instance, usually this.
-
arg
Add an argument to the event being built. Synonymous withaddArgument(Object)
method.- Parameters:
p
- an Object to add.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
addArgument
Add an argument supplier to the event being built. Synonymous with
arg(Supplier)
method.- Parameters:
objectSupplier
- an Object supplier to add.- Returns:
- a LoggingEventBuilder instance, usually this.
-
arg
Add an argument supplier to the event being built. Synonymous with
addArgument(Supplier)
method.- Parameters:
objectSupplier
- an Object supplier to add.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
arg
Add a value of typeboolean
to the event being built.The default implementation simply casts to
Boolean
. However, the NOP implementation, i.e.NOPLoggingEventBuilder
, skips the cast.- Parameters:
b
- a value of typeboolean
value to add.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
arg
Add a value of typechar
to the event being built.The default implementation simply casts to
Character
. However, the NOP implementation, i.e.NOPLoggingEventBuilder
, skips the cast.- Parameters:
c
- a value of typechar
value to add.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
arg
Add a value of typebyte
to the event being built.The default implementation simply casts to
Byte
. However, the NOP implementation, i.e.NOPLoggingEventBuilder
, skips the cast.- Parameters:
b
- a value of typebyte
value to add.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
arg
Add a value of typeshort
to the event being built.The default implementation simply casts to
Short
. However, the NOP implementation, i.e.NOPLoggingEventBuilder
, skips the cast.- Parameters:
s
- a value of typeshort
value to add.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
arg
Add a value of typeint
to the event being built.The default implementation simply casts to
Integer
. However, the NOP implementation, i.e.NOPLoggingEventBuilder
, skips the cast.- Parameters:
i
- a value of typeint
value to add.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
arg
Add a value of typelong
to the event being built.The default implementation simply casts to
Long
. However, the NOP implementation, i.e.NOPLoggingEventBuilder
, skips the cast.- Parameters:
l
- a value of typelong
value to add.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
arg
Add a value of typefloat
to the event being built.The default implementation simply casts to
Float
. However, the NOP implementation, i.e.NOPLoggingEventBuilder
, skips the cast.- Parameters:
f
- a value of typefloat
value to add.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
arg
Add a value of typedouble
to the event being built.The default implementation simply casts to
Double
. However, the NOP implementation skips the cast.- Parameters:
d
- a value of typedouble
value to add.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
addKeyValue
Add akey value pair
to the event being built.- Parameters:
key
- the key of the key value pair.value
- the value of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
-
kv
Add akey value pair
to the event being built. Synonymous withaddKeyValue(String, Object)
method.- Parameters:
key
- the key of the key value pair.value
- the value of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
addKeyValue
Add akey value pair
to the event being built.- Parameters:
key
- the key of the key value pair.valueSupplier
- a supplier of a value for the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
-
kv
Add akey value pair
to the event being built. Synonymous withaddKeyValue(String, Supplier)
method.- Parameters:
key
- the key of the key value pair.valueSupplier
- a supplier of a value for the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
kv
Add a
key value pair
to the event being built, with the value part being of typeboolean
.The default implementation simply casts to value part to
Boolean
before callingaddKeyValue(String, Object)
. However, the NOP implementation, i.eNOPLoggingEventBuilder
, skips the cast.- Parameters:
key
- the key of the key value pair.b
- the value of typeboolean
of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
kv
Add a
key value pair
to the event being built, with the value part being of typechar
.The default implementation simply casts to value part to
Character
before callingaddKeyValue(String, Object)
. However, the NOP implementation, i.eNOPLoggingEventBuilder
, skips the cast.- Parameters:
key
- the key of the key value pair.c
- the value of typechar
of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
kv
Add a
key value pair
to the event being built, with the value part being of typebyte
.The default implementation simply casts to value part to
Byte
before callingaddKeyValue(String, Object)
. However, the NOP implementation, i.eNOPLoggingEventBuilder
, skips the cast.- Parameters:
key
- the key of the key value pair.b
- the value of typebyte
of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
kv
Add a
key value pair
to the event being built, with the value part being of typeshort
.The default implementation simply casts to value part to
Short
before callingaddKeyValue(String, Object)
. However, the NOP implementation, i.eNOPLoggingEventBuilder
, skips the cast.- Parameters:
key
- the key of the key value pair.s
- the value of typeshort
of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
kv
Add a
key value pair
to the event being built, with the value part being of typeint
.The default implementation simply casts to value part to
Integer
before callingaddKeyValue(String, Object)
. However, the NOP implementation, i.eNOPLoggingEventBuilder
, skips the cast.- Parameters:
key
- the key of the key value pair.i
- the value of typeint
of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
kv
Add a
key value pair
to the event being built, with the value part being of typelong
.The default implementation simply casts to value part to
Integer
before callingaddKeyValue(String, Object)
. However, the NOP implementation, i.eNOPLoggingEventBuilder
, skips the cast.- Parameters:
key
- the key of the key value pair.l
- the value of typelong
of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
kv
Add a
key value pair
to the event being built, with the value part being of typefloat
.The default implementation simply casts to value part to
Float
before callingaddKeyValue(String, Object)
. However, the NOP implementation, i.eNOPLoggingEventBuilder
, skips the cast.- Parameters:
key
- the key of the key value pair.f
- the value of typefloat
of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
kv
Add a
key value pair
to the event being built, with the value part being of typedouble
.The default implementation simply casts to value part to
Double
before callingaddKeyValue(String, Object)
. However, the NOP implementation, i.eNOPLoggingEventBuilder
, skips the cast.- Parameters:
key
- the key of the key value pair.f
- the value of typedouble
of the key value pair.- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.1.0
-
setMessage
Sets the message of the logging event.- Parameters:
message
- the message of the event- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.0.0
-
setMessage
Sets the message of the event via a message supplier.- Parameters:
messageSupplier
- supplies a String to be used as the message for the event- Returns:
- a LoggingEventBuilder instance, usually this.
- Since:
- 2.0.0-beta0
-
log
void log()After the logging event is built, performs actual logging. This method must be called for logging to occur. If the call tolog()
is omitted, aLoggingEvent
will be built but no logging will occur.- Since:
- 2.0.0-beta0
-
log
Equivalent to callingsetMessage(String)
followed bylog()
;- Parameters:
message
- the message to log
-
log
- Parameters:
message
- the message to logarg
- an argument to be used with the message to log
-
log
Equivalent to callingsetMessage(String)
followed by two calls toaddArgument(Object)
and thenlog()
- 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
Equivalent to callingsetMessage(String)
followed by zero or more calls toaddArgument(Object)
(depending on the size of args array) and thenlog()
- Parameters:
message
- the message to logargs
- a list (actually an array) of arguments to be used with the message to log
-
log
Equivalent to callingsetMessage(Supplier)
followed bylog()
- Parameters:
messageSupplier
- a Supplier returning a message of type String
-