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

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

public class CustomFileOfCallerConverter extends ClassicConverter {
	public String convert(ILoggingEvent le) {
		StackTraceElement[] cda = le.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].getFileName();
				}
				return cda[1].getFileName();
			}
			return cda[0].getFileName();
		} else {
			return "?";
		}
	}
}