Skip to content

Commit e0c389b

Browse files
authored
Log level mapping according to Android docs (#42)
1 parent 503324b commit e0c389b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

lib/src/main/kotlin/at/bitfire/synctools/log/LogcatHandler.kt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import java.util.logging.LogRecord
1616
/**
1717
* Logging handler that logs to Android logcat.
1818
*
19+
* Log level mapping: https://source.android.com/docs/core/tests/debug/understanding-logging#log-standards
20+
*
1921
* @param fallbackTag adb tag to use if class name can't be determined
2022
*/
2123
class LogcatHandler(
@@ -47,11 +49,20 @@ class LogcatHandler(
4749
tag
4850

4951
when {
50-
level >= Level.SEVERE.intValue() -> Log.e(tagOrTruncated, text, r.thrown)
51-
level >= Level.WARNING.intValue() -> Log.w(tagOrTruncated, text, r.thrown)
52-
level >= Level.CONFIG.intValue() -> Log.i(tagOrTruncated, text, r.thrown)
53-
level >= Level.FINER.intValue() -> Log.d(tagOrTruncated, text, r.thrown)
54-
else -> Log.v(tagOrTruncated, text, r.thrown)
52+
level >= Level.SEVERE.intValue() ->
53+
Log.e(tagOrTruncated, text, r.thrown)
54+
55+
level >= Level.WARNING.intValue() ->
56+
Log.w(tagOrTruncated, text, r.thrown)
57+
58+
level >= Level.INFO.intValue() ->
59+
Log.i(tagOrTruncated, text, r.thrown)
60+
61+
level >= Level.FINE.intValue() -> // CONFIG, FINE
62+
Log.d(tagOrTruncated, text, r.thrown)
63+
64+
else -> // FINER, FINEST
65+
Log.v(tagOrTruncated, text, r.thrown)
5566
}
5667
}
5768

0 commit comments

Comments
 (0)