All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.huxhorn.lilith.logback.encoder.WrappingClassicEncoder Maven / Gradle / Ivy

There is a newer version: 8.3.0
Show newest version
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);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy