Skip to content

Instantly share code, notes, and snippets.

@pyeongho
Created April 12, 2019 00:06
Show Gist options
  • Save pyeongho/9033b0d6201bd205214489cdcb4caf11 to your computer and use it in GitHub Desktop.
Save pyeongho/9033b0d6201bd205214489cdcb4caf11 to your computer and use it in GitHub Desktop.
public class log {
public static final String tag = "phkim";
public final static boolean debug = BuildConfig.DEBUG;
public static void l() {
try {
if (debug) {
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
Log.d(tag, "("+element[1].getFileName()+":"+element[1].getLineNumber()+")"+"\t"+element[1].getMethodName() );
}
} catch (Exception ignore) {
}
}
public static void d(String msg) {
try {
if (debug) {
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
Log.d(tag, "("+element[1].getFileName()+":"+element[1].getLineNumber()+")"+"\t"+element[1].getMethodName() + " -> " + msg);
}
} catch (Exception ignore) {
}
}
public static void d(String _tag, String msg) {
try {
if (debug){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
Log.d(_tag, "("+element[1].getFileName()+":"+element[1].getLineNumber()+")"+"\t"+element[1].getMethodName() + " -> " + msg);
}
} catch (Exception ignore) {
}
}
public static void e(String msg) {
try {
if (debug){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
Log.e(tag, "("+element[1].getFileName()+":"+element[1].getLineNumber()+")"+"\t"+element[1].getMethodName() + " -> " + msg);
}
} catch (Exception ignore) {
}
}
public static void w(String msg) {
try {
if (debug){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
Log.w(tag, "("+element[1].getFileName()+":"+element[1].getLineNumber()+")"+"\t"+element[1].getMethodName() + " -> " + msg);
}
} catch (Exception ignore) {
}
}
public static void i(String msg) {
try {
if (debug){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
Log.i(tag, "("+element[1].getFileName()+":"+element[1].getLineNumber()+")"+"\t"+element[1].getMethodName() + " -> " + msg);
}
} catch (Exception ignore) {
}
}
public static void v(String msg) {
try {
if (debug){
Exception e = new Exception();
StackTraceElement[] element = e.getStackTrace();
Log.v(tag, "("+element[1].getFileName()+":"+element[1].getLineNumber()+")"+"\t"+element[1].getMethodName() + " -> " + msg);
}
} catch (Exception ignore) {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment