package com.eactive.eai.common.util.logger;

import ch.qos.logback.classic.pattern.NamedConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;

public class CustomClassOfCallerConverter extends NamedConverter {
	protected String getFullyQualifiedName(ILoggingEvent event) {
		StackTraceElement[] cda = event.getCallerData();
		if (cda != null && cda.length > 0) {
			if (cda[0].getFileName().equals("Logger.java") && cda.length > 1) {
				if (cda[1].getFileName().equals("Logger.java") && cda.length > 2){
					return cda[2].getClassName();
				}
				return cda[1].getClassName();
			}
			return cda[0].getClassName();
		} else {
			return "?";
		}
	}
}