com.sap.hcp.cf.logback.encoder.ChildConverterContextInjector Maven / Gradle / Ivy
package com.sap.hcp.cf.logback.encoder;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.pattern.CompositeConverter;
import ch.qos.logback.core.pattern.Converter;
import ch.qos.logback.core.pattern.PostCompileProcessor;
import ch.qos.logback.core.spi.ContextAware;
public class ChildConverterContextInjector implements PostCompileProcessor {
@Override
public void process(Context context, Converter head) {
inject(context, head, false);
}
private void inject(Context context, Converter head, boolean injectAll) {
for (Converter c = head; c != null; c = c.getNext()) {
if (c instanceof CompositeConverter>) {
Converter childConverter = ((CompositeConverter) c).getChildConverter();
inject(context, childConverter, true);
}
if (injectAll && c instanceof ContextAware) {
((ContextAware) c).setContext(context);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy