* The deault log level is {@link NonAndroidLog#VERBOSE} *
* * @param logLevel LogLevel to use to filter log output. */ public void setLogLevel(int logLevel) { this.logLevel = logLevel; } public int v(String tag, String msg) { if (logLevel <= VERBOSE) { out.println(tag + " : " + msg); } return 0; } public int v(String tag, String msg, Throwable tr) { if (logLevel <= VERBOSE) { out.println(tag + " : " + msg); tr.printStackTrace(out); } return 0; } public int d(String tag, String msg) { if (logLevel <= DEBUG) { out.println(tag + " : " + msg); } return 0; } public int d(String tag, String msg, Throwable tr) { if (logLevel <= DEBUG) { out.println(tag + " : " + msg); tr.printStackTrace(out); } return 0; } public int i(String tag, String msg) { if (logLevel <= INFO) { out.println(tag + " : " + msg); } return 0; } public int i(String tag, String msg, Throwable tr) { if (logLevel <= INFO) { out.println(tag + " : " + msg); tr.printStackTrace(out); } return 0; } public int w(String tag, String msg) { if (logLevel <= WARN) { out.println(tag + " : " + msg); } return 0; } public int w(String tag, String msg, Throwable tr) { if (logLevel <= WARN) { out.println(tag + " : " + msg); tr.printStackTrace(out); } return 0; } //public native boolean isLoggable(java.lang.String tag, int level); public int w(String tag, Throwable tr) { return Log.w(tag, tr); } public int e(String tag, String msg) { if (logLevel <= ERROR) { out.println(tag + " : " + msg); } return 0; } public int e(String tag, String msg, Throwable tr) { if (logLevel <= ERROR) { out.println(tag + " : " + msg); tr.printStackTrace(out); } return 0; } public String getStackTraceString(Throwable tr) { final Writer result = new StringWriter(); final PrintWriter printWriter = new PrintWriter(result); // If the exception was thrown in a background thread inside // AsyncTask, then the actual exception can be found with getCause Throwable cause = tr; while (cause != null) { cause.printStackTrace(printWriter); cause = cause.getCause(); } final String stacktraceAsString = result.toString(); printWriter.close(); return stacktraceAsString; } //public native int println(int priority, java.lang.String tag, java.lang.String msg); }