com.agido.logback.elasticsearch.util.AbstractPropertyAndEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of logback-elasticsearch-appender Show documentation
Show all versions of logback-elasticsearch-appender Show documentation
Send log events directly from Logback to Elasticsearch
The newest version!
package com.agido.logback.elasticsearch.util;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.pattern.PatternLayoutBase;
import com.agido.logback.elasticsearch.config.Property;
public abstract class AbstractPropertyAndEncoder {
private Property property;
private PatternLayoutBase layout;
public AbstractPropertyAndEncoder(Property property, Context context) {
this.property = property;
this.layout = getLayout();
this.layout.setContext(context);
this.layout.setPattern(property.getValue());
this.layout.setPostCompileProcessor(null);
this.layout.start();
}
protected abstract PatternLayoutBase getLayout();
public String encode(T event) {
return layout.doLayout(event);
}
public String getName() {
return property.getName();
}
public boolean allowEmpty() {
return property.isAllowEmpty();
}
public Property.Type getType() {
return property.getType();
}
}