Package net.logstash.logback.pattern
Class PatternLayoutAdapter<E>
java.lang.Object
net.logstash.logback.pattern.PatternLayoutAdapter<E>
Adapter around a
PatternLayoutBase
to allow writing the pattern into a supplied StringBuilder
instead of returning a String.
The adapter also throws an IllegalArgumentException
upon start when the configured pattern is not a
valid pattern layout instead of simply emitting an ERROR status.- Author:
- brenuart
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the constant value of the pattern or throw anIllegalStateException
if the pattern is not constant.boolean
Indicate whether thePatternLayoutBase
always generates the same constant value regardless of the event it is given.void
setContext
(Context context) Set theContext
void
setPattern
(String pattern) Set the layout patternvoid
start()
Start the underlying PatternLayoutBase and throw anIllegalArgumentException
if the configured pattern is not a valid PatternLayout.void
writeTo
(StringBuilder strBuilder, E event) Apply the PatternLayout to the event and write result into the suppliedStringBuilder
.
-
Constructor Details
-
PatternLayoutAdapter
-
-
Method Details
-
setContext
Set theContext
- Parameters:
context
- the context
-
setPattern
Set the layout pattern- Parameters:
pattern
- the layout pattern
-
start
Start the underlying PatternLayoutBase and throw anIllegalArgumentException
if the configured pattern is not a valid PatternLayout.- Throws:
IllegalArgumentException
- thrown when the configured pattern is not a valid PatternLayout
-
writeTo
Apply the PatternLayout to the event and write result into the suppliedStringBuilder
.- Parameters:
strBuilder
- theStringBuilder
to write the result of applying the PatternLayout on the eventevent
- the event to apply the pattern to
-
isConstant
public boolean isConstant()Indicate whether thePatternLayoutBase
always generates the same constant value regardless of the event it is given.- Returns:
- true if the pattern is constant
-
getConstantValue
Get the constant value of the pattern or throw anIllegalStateException
if the pattern is not constant.- Returns:
- the constant value of the pattern
- See Also:
-