use of com.nextdoor.bender.operation.substitution.Substitution in project bender by Nextdoor.
the class GelfOperationFactory method setConf.
@Override
public void setConf(AbstractConfig config) {
this.config = (GelfOperationConfig) config;
ArrayList<SubstitutionConfig> subConfigs = new ArrayList<SubstitutionConfig>();
subConfigs.add(new StaticSubstitutionConfig("version", "1.1", true));
if (this.config.getSrcHostField() != null) {
subConfigs.add(new FieldSubstitutionConfig("host", this.config.getSrcHostField(), false, true, true));
}
if (this.config.getSrcShortMessageField() != null) {
subConfigs.add(new FieldSubstitutionConfig("short_message", this.config.getSrcShortMessageField(), false, true, true));
}
if (this.config.getSrcFullMessageField() != null) {
subConfigs.add(new FieldSubstitutionConfig("full_message", this.config.getSrcFullMessageField(), false, false, true));
}
if (this.config.getSrcTimestampField() != null) {
subConfigs.add(new FieldSubstitutionConfig("timestamp", this.config.getSrcTimestampField(), false, false, true));
}
if (this.config.getSrcLevelField() != null) {
subConfigs.add(new FieldSubstitutionConfig("level", this.config.getSrcLevelField(), false, false, true));
}
if (this.config.getSrcFacilityField() != null) {
subConfigs.add(new FieldSubstitutionConfig("facility", this.config.getSrcFacilityField(), false, false, true));
}
if (this.config.getSrcLineNumberField() != null) {
subConfigs.add(new FieldSubstitutionConfig("line", this.config.getSrcLineNumberField(), false, false, true));
}
if (this.config.getSrcFileField() != null) {
subConfigs.add(new FieldSubstitutionConfig("file", this.config.getSrcFileField(), false, false, true));
}
List<Substitution> substitutions = new ArrayList<Substitution>(subConfigs.size());
SubstitutionFactoryFactory sff = new SubstitutionFactoryFactory();
for (SubstitutionConfig subConfig : subConfigs) {
try {
substitutions.add(sff.getFactory(subConfig).newInstance());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
this.substitutions = substitutions;
this.subConfigs = subConfigs;
}
Aggregations