Add method for get caller prefix

Former-commit-id: d04294b6f0bac367ff24a66c02b37fba140a79b0 [formerly feb875dbed966d16f38b287c79da9363a7a5c2c5]
Former-commit-id: 8a80d51b0520478eef24d241fc1c1e7fd03a43a5
This commit is contained in:
Ghost_chu committed 2019-07-16 19:34:31 +08:00
1 parent 4b886ebd51
commit c773b74860
1 file changed
+17
@@ -829,6 +829,23 @@ public class Util {
}
}
/**
* Return the Class name.
*/
public static String getClassPrefix() {
String className = Thread.currentThread().getStackTrace()[2].getClassName();
try {
Class c = Class.forName(className);
className = c.getSimpleName();
if (!c.getSimpleName().isEmpty())
className = c.getSimpleName();
} catch (ClassNotFoundException e) {
//Ignore
}
String methodName = Thread.currentThread().getStackTrace()[2].getMethodName();
return "[" + className + "-" + methodName + "] ";
}
/**
* Get how many shop in the target world.
*