Skip to content

Commit

Permalink
make logging configurable (#242)
Browse files Browse the repository at this point in the history
the logging level is INFO by default, and can be overridden with setprop or
/data/local.prop file (changing the latter requires rebooting the device)

for details see
https://developer.android.com/reference/android/util/Log#isLoggable(java.lang.String,%20int)
  • Loading branch information
sshock authored and mykola-mokhnach committed Jan 11, 2019
1 parent 65e708b commit 20de622
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/src/main/java/io/appium/uiautomator2/utils/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,35 @@ private static String getString(Object... args) {
* Logger error
*/
public static void error(Object... messages) {
android.util.Log.e(TAG, getString(messages));
if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) {
android.util.Log.e(TAG, getString(messages));
}
}

/**
* Logger error
*/
public static void error(String message, Throwable throwable) {
android.util.Log.e(TAG, getString(message), throwable);
if (android.util.Log.isLoggable(TAG, android.util.Log.ERROR)) {
android.util.Log.e(TAG, getString(message), throwable);
}
}

/**
* Logger info
*/
public static void info(Object... messages) {
android.util.Log.i(TAG, getString(messages));
if (android.util.Log.isLoggable(TAG, android.util.Log.INFO)) {
android.util.Log.i(TAG, getString(messages));
}
}

/**
* Logger debug
*/
public static void debug(Object... messages) {
android.util.Log.d(TAG, getString(messages));
if (android.util.Log.isLoggable(TAG, android.util.Log.DEBUG)) {
android.util.Log.d(TAG, getString(messages));
}
}
}

0 comments on commit 20de622

Please sign in to comment.