Created
February 20, 2012 05:13
-
-
Save ajaykumarns/1867957 to your computer and use it in GitHub Desktop.
Simple Logger in android that allows var-arg style logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.util.Log; | |
import static java.lang.String.format; | |
/** | |
* @author Ajay Kumar.N.S | |
* @since 1.0, 12/28/11, 11:52 PM | |
*/ | |
public final class Logger { | |
public final String tag; | |
public static Logger forK(Class<?> klas){ | |
return new Logger(klas.getSimpleName()); | |
} | |
public Logger(String tag) { | |
this.tag = tag; | |
} | |
public void debug(String msg) { | |
Log.d(tag, msg); | |
} | |
public void info(String msg) { | |
Log.i(tag, msg); | |
} | |
public void warn(String msg) { | |
Log.w(tag, msg); | |
} | |
public void wtf(String msg) { | |
Log.e(tag, msg); | |
} | |
public void debug(String msg, Object... params) { | |
Log.d(tag, format(msg, params)); | |
} | |
public void info(String msg, Object... params) { | |
Log.i(tag, format(msg, params)); | |
} | |
public void warn(String msg, Object... params) { | |
Log.w(tag, format(msg, params)); | |
} | |
public void wtf(String msg, Object... params) { | |
Log.e(tag, format(msg, params)); | |
} | |
public void err(String msg, Throwable err){ | |
Log.e(tag, msg, err); | |
} | |
public void err(Throwable err){ | |
Log.e(tag, "error occurred", err); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment