Skip to content

Instantly share code, notes, and snippets.

@pyeongho
Created January 16, 2017 05:27
Show Gist options
  • Save pyeongho/aba74627329e1a57eb1065a0df590fa6 to your computer and use it in GitHub Desktop.
Save pyeongho/aba74627329e1a57eb1065a0df590fa6 to your computer and use it in GitHub Desktop.
public class log {
public static final String tag = "PYEONGHO";
public final static boolean debug = BuildConfig.DEBUG;
public final static boolean debug1 = true;
private static boolean getDebug(){
if(debug && debug1){
return true;
}else{
return false;
}
}
public static void l(){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
if(getDebug()) Log.d(tag, element[1].getFileName() + "\t[Line:" + element[1].getLineNumber() + "]\t" + element[1].getMethodName());
}
public static void d(String msg){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
if(getDebug()) Log.d(tag, element[1].getFileName() + "\t[Line:" + element[1].getLineNumber() + "]\t" + element[1].getMethodName() + " -> " + msg);
}
public static void e(String msg){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
if(getDebug()) Log.e(tag,element[1].getFileName()+"\t[Line:"+ element[1].getLineNumber()+"]\t" + element[1].getMethodName() + " -> " + msg);
}
public static void w(String msg){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
if(getDebug()) Log.w(tag,element[1].getFileName()+"\t[Line:"+ element[1].getLineNumber()+"]\t" + element[1].getMethodName() + " -> " + msg);
}
public static void i(String msg){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
if(getDebug()) Log.i(tag,element[1].getFileName()+"\t[Line:"+ element[1].getLineNumber()+"]\t" + element[1].getMethodName() + " -> " + msg);
}
public static void v(String msg){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
if(getDebug()) Log.v(tag,element[1].getFileName()+"\t[Line:"+ element[1].getLineNumber()+"]\t" + element[1].getMethodName() + " -> " + msg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment