Fix Android logs from java.
Some levels where hidden due to the use of isLoggable.
This commit is contained in:
parent
8321234251
commit
a68b03baab
1 changed files with 21 additions and 12 deletions
|
@ -18,7 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
package org.linphone.core;
|
||||
|
||||
|
||||
import static android.util.Log.DEBUG;
|
||||
import static android.util.Log.ERROR;
|
||||
import static android.util.Log.INFO;
|
||||
import static android.util.Log.WARN;
|
||||
|
||||
/**
|
||||
* Convenient wrapper for Android logs.
|
||||
|
@ -28,48 +31,54 @@ package org.linphone.core;
|
|||
public final class Log {
|
||||
|
||||
public static final String TAG = "Linphone";
|
||||
private static final boolean useIsLoggable = false;
|
||||
|
||||
@SuppressWarnings(value="all")
|
||||
private static boolean isLoggable(int level) {
|
||||
return !useIsLoggable || android.util.Log.isLoggable(TAG, level);
|
||||
}
|
||||
|
||||
public static void i(Object...objects) {
|
||||
if (android.util.Log.isLoggable(TAG, android.util.Log.INFO)) {
|
||||
if (isLoggable(INFO)) {
|
||||
android.util.Log.i(TAG, toString(objects));
|
||||
}
|
||||
}
|
||||
public static void i(Throwable t, Object...objects) {
|
||||
if (android.util.Log.isLoggable(TAG, android.util.Log.INFO)) {
|
||||
if (isLoggable(INFO)) {
|
||||
android.util.Log.i(TAG, toString(objects), t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void d(Object...objects) {
|
||||
if (android.util.Log.isLoggable(TAG, android.util.Log.DEBUG)) {
|
||||
if (isLoggable(DEBUG)) {
|
||||
android.util.Log.d(TAG, toString(objects));
|
||||
}
|
||||
}
|
||||
public static void d(Throwable t, Object...objects) {
|
||||
if (android.util.Log.isLoggable(TAG, android.util.Log.DEBUG)) {
|
||||
if (isLoggable(DEBUG)) {
|
||||
android.util.Log.d(TAG, toString(objects), t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void w(Object...objects) {
|
||||
if (android.util.Log.isLoggable(TAG, android.util.Log.WARN)) {
|
||||
if (isLoggable(WARN)) {
|
||||
android.util.Log.w(TAG, toString(objects));
|
||||
}
|
||||
}
|
||||
public static void w(Throwable t, Object...objects) {
|
||||
if (android.util.Log.isLoggable(TAG, android.util.Log.WARN)) {
|
||||
if (isLoggable(WARN)) {
|
||||
android.util.Log.w(TAG, toString(objects), t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void e(Object...objects) {
|
||||
if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) {
|
||||
if (isLoggable(ERROR)) {
|
||||
android.util.Log.e(TAG, toString(objects));
|
||||
}
|
||||
}
|
||||
public static void e(Throwable t, Object...objects) {
|
||||
if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) {
|
||||
if (isLoggable(ERROR)) {
|
||||
android.util.Log.e(TAG, toString(objects), t);
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +87,7 @@ public final class Log {
|
|||
* @throws RuntimeException always throw after logging the error message.
|
||||
*/
|
||||
public static void f(Object...objects) {
|
||||
if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) {
|
||||
if (isLoggable(ERROR)) {
|
||||
android.util.Log.e(TAG, toString(objects));
|
||||
throw new RuntimeException("Fatal error : " + toString(objects));
|
||||
}
|
||||
|
@ -87,7 +96,7 @@ public final class Log {
|
|||
* @throws RuntimeException always throw after logging the error message.
|
||||
*/
|
||||
public static void f(Throwable t, Object...objects) {
|
||||
if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) {
|
||||
if (isLoggable(ERROR)) {
|
||||
android.util.Log.e(TAG, toString(objects), t);
|
||||
throw new RuntimeException("Fatal error : " + toString(objects), t);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue