Skip to content

Instantly share code, notes, and snippets.

@VictorAlbertos
Created September 2, 2015 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VictorAlbertos/5cebd47a1556964b2e7d to your computer and use it in GitHub Desktop.
Save VictorAlbertos/5cebd47a1556964b2e7d to your computer and use it in GitHub Desktop.
private static class Emitter {
private final String className, methodName, lineNumber;
public Emitter() {
this.className = getNameCurrentClassExecution();
this.methodName = getNameCurrentMethodExecution();
this.lineNumber = getLineNumberExecution();
}
public String getClassName() {
return className;
}
public String getMethodName() {
return methodName;
}
public String getLineNumber() {
return lineNumber;
}
private String getNameCurrentClassExecution() {
return getBottomStackTraceElement().getClassName();
}
private String getNameCurrentMethodExecution() {
return getBottomStackTraceElement().getMethodName();
}
private String getLineNumberExecution() {
return String.valueOf(getBottomStackTraceElement().getLineNumber());
}
private StackTraceElement getBottomStackTraceElement() {
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
return stackTraceElements[stackTraceElements.length -1];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment