public class Logback11Support extends Object
Encoder
interface was changed from
writing to an OutputStream
to returning byte arrays.
This was a backwards incompatible change, therefore some fancy runtime reflection
is required to make logstash-logback-encoder work with both pre- and post-1.2 logback versions.
This class is used to determine if logback 1.1 is on the runtime classpath (isLogback11OrBefore()
),
and invoke the old methods on the Encoder
interface.Modifier and Type | Field and Description |
---|---|
static Logback11Support |
INSTANCE |
Constructor and Description |
---|
Logback11Support() |
Modifier and Type | Method and Description |
---|---|
void |
close(Encoder<?> encoder)
Invokes the close method of a logback 1.1 encoder.
|
void |
doEncode(Encoder<?> encoder,
Object event)
Invokes the doEncode method of a logback 1.1 encoder, with the given event as the argument.
|
void |
init(Encoder<?> encoder,
OutputStream outputStream)
Invokes the init method of a logback 1.1 encoder, with the given outputStream as the argument.
|
boolean |
isLogback11OrBefore() |
void |
verifyLogback11OrBefore()
Called by logic that should only execute if logback 1.1.x or earlier is on the runtime classpath.
|
void |
verifyLogback12OrAfter()
Called by logic that should only execute if logback 1.2.x or later is on the runtime classpath.
|
public static final Logback11Support INSTANCE
public boolean isLogback11OrBefore()
public void verifyLogback11OrBefore()
IllegalStateException
- if the logback version is >= 1.2public void verifyLogback12OrAfter()
IllegalStateException
- if the logback version is < 1.2public void init(Encoder<?> encoder, OutputStream outputStream) throws IOException
encoder
- the encoder to initializeoutputStream
- the output stream with which to initialize the encoderIOException
- if an exception occurs during initializationpublic void doEncode(Encoder<?> encoder, Object event) throws IOException
encoder
- the encoder to use to encode the eventevent
- the event to encodeIOException
- if an exception occurs during encodingpublic void close(Encoder<?> encoder) throws IOException
encoder
- the encoder to closeIOException
- if an exception occurs during closeCopyright © 2020. All rights reserved.