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 anIllegalStateExceptionif the pattern is not constant.booleanIndicate whether thePatternLayoutBasealways generates the same constant value regardless of the event it is given.voidsetContext(Context context) Set theContextvoidsetPattern(String pattern) Set the layout patternvoidstart()Start the underlying PatternLayoutBase and throw anIllegalArgumentExceptionif the configured pattern is not a valid PatternLayout.voidwriteTo(StringBuilder strBuilder, E event) Apply the PatternLayout to the event and write result into the suppliedStringBuilder.
-
Constructor Details
-
PatternLayoutAdapter
-
-
Method Details
-
setContext
-
setPattern
Set the layout pattern- Parameters:
pattern- the layout pattern
-
start
Start the underlying PatternLayoutBase and throw anIllegalArgumentExceptionif 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- theStringBuilderto write the result of applying the PatternLayout on the eventevent- the event to apply the pattern to
-
isConstant
public boolean isConstant()Indicate whether thePatternLayoutBasealways 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 anIllegalStateExceptionif the pattern is not constant.- Returns:
- the constant value of the pattern
- See Also:
-