[DEV] remove error of backtrace

This commit is contained in:
Edouard DUPIN 2021-06-22 07:54:00 +02:00
parent 52fe5db109
commit 5b6125bec2

View File

@ -163,7 +163,22 @@ public class Logger {
}
private static StackTraceElement getCallerElement() {
return Thread.currentThread().getStackTrace()[5];
if (Thread.currentThread().getStackTrace().length > 5) {
return Thread.currentThread().getStackTrace()[5];
}
if (Thread.currentThread().getStackTrace().length > 4) {
return Thread.currentThread().getStackTrace()[4];
}
if (Thread.currentThread().getStackTrace().length > 3) {
return Thread.currentThread().getStackTrace()[3];
}
if (Thread.currentThread().getStackTrace().length > 2) {
return Thread.currentThread().getStackTrace()[2];
}
if (Thread.currentThread().getStackTrace().length > 1) {
return Thread.currentThread().getStackTrace()[1];
}
return Thread.currentThread().getStackTrace()[0];
}
/** This function permit to get the printable string to print in the log element (select here the number of char to print)