Skip to content

Instantly share code, notes, and snippets.

@Faisal-FS
Last active December 3, 2022 18:44
Show Gist options
  • Select an option

  • Save Faisal-FS/11a87f8c302c6ae472053c6f9f27b535 to your computer and use it in GitHub Desktop.

Select an option

Save Faisal-FS/11a87f8c302c6ae472053c6f9f27b535 to your computer and use it in GitHub Desktop.
This is a reference code for the video "https://youtube.com/shorts/-swdK0vKcgM"
public class LogUtil {
public static String getTag(){
StackTraceElement element = new Exception().getStackTrace()[1];
String tag = element.getClassName();
Matcher m = Pattern.compile("(\\$\\d+)+$").matcher(tag);
if (m.find()) {
tag = m.replaceAll("");
}
return tag.substring(tag.lastIndexOf('.') + 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment