de.huxhorn.lilith.logback.encoder.WrappingClassicEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of de.huxhorn.lilith.logback.encoder.classic Show documentation
Show all versions of de.huxhorn.lilith.logback.encoder.classic Show documentation
This file is part of Lilith. It contains the classic encoder.
package de.huxhorn.lilith.logback.encoder;
import ch.qos.logback.classic.spi.ILoggingEvent;
import de.huxhorn.lilith.data.converter.Converter;
import de.huxhorn.lilith.data.eventsource.EventWrapper;
import de.huxhorn.lilith.data.logging.logback.SameThreadLogbackLoggingConverter;
import de.huxhorn.lilith.data.logging.protobuf.CompressingLoggingEventWrapperProtobufCodec;
import de.huxhorn.sulky.codec.Codec;
import de.huxhorn.sulky.codec.Encoder;
public class WrappingClassicEncoder
implements Encoder
{
private Converter converter = new SameThreadLogbackLoggingConverter();
private Codec> codec = new CompressingLoggingEventWrapperProtobufCodec();
private long id;
public void reset()
{
id=0;
}
public byte[] encode(ILoggingEvent event)
{
de.huxhorn.lilith.data.logging.LoggingEvent lilithEvent = converter.convert(event);
EventWrapper wrapped=new EventWrapper<>();
wrapped.setEvent(lilithEvent);
//wrapped.setEventIdentifier();
id++;
wrapped.setLocalId(id);
//wrapped.setSourceIdentifier();
return codec.encode(wrapped);
}
}