mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Annotate log methods with @Pure
PiperOrigin-RevId: 352519583
This commit is contained in:
parent
0c22810a7b
commit
fc952bfba2
@ -22,6 +22,7 @@ import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.net.UnknownHostException;
|
||||
import org.checkerframework.dataflow.qual.Pure;
|
||||
|
||||
/** Wrapper around {@link android.util.Log} which allows to set the log level. */
|
||||
public final class Log {
|
||||
@ -51,11 +52,13 @@ public final class Log {
|
||||
private Log() {}
|
||||
|
||||
/** Returns current {@link LogLevel} for ExoPlayer logcat logging. */
|
||||
@Pure
|
||||
public static @LogLevel int getLogLevel() {
|
||||
return logLevel;
|
||||
}
|
||||
|
||||
/** Returns whether stack traces of {@link Throwable}s will be logged to logcat. */
|
||||
@Pure
|
||||
public boolean getLogStackTraces() {
|
||||
return logStackTraces;
|
||||
}
|
||||
@ -80,6 +83,7 @@ public final class Log {
|
||||
}
|
||||
|
||||
/** @see android.util.Log#d(String, String) */
|
||||
@Pure
|
||||
public static void d(String tag, String message) {
|
||||
if (logLevel == LOG_LEVEL_ALL) {
|
||||
android.util.Log.d(tag, message);
|
||||
@ -87,11 +91,13 @@ public final class Log {
|
||||
}
|
||||
|
||||
/** @see android.util.Log#d(String, String, Throwable) */
|
||||
@Pure
|
||||
public static void d(String tag, String message, @Nullable Throwable throwable) {
|
||||
d(tag, appendThrowableString(message, throwable));
|
||||
}
|
||||
|
||||
/** @see android.util.Log#i(String, String) */
|
||||
@Pure
|
||||
public static void i(String tag, String message) {
|
||||
if (logLevel <= LOG_LEVEL_INFO) {
|
||||
android.util.Log.i(tag, message);
|
||||
@ -99,11 +105,13 @@ public final class Log {
|
||||
}
|
||||
|
||||
/** @see android.util.Log#i(String, String, Throwable) */
|
||||
@Pure
|
||||
public static void i(String tag, String message, @Nullable Throwable throwable) {
|
||||
i(tag, appendThrowableString(message, throwable));
|
||||
}
|
||||
|
||||
/** @see android.util.Log#w(String, String) */
|
||||
@Pure
|
||||
public static void w(String tag, String message) {
|
||||
if (logLevel <= LOG_LEVEL_WARNING) {
|
||||
android.util.Log.w(tag, message);
|
||||
@ -111,11 +119,13 @@ public final class Log {
|
||||
}
|
||||
|
||||
/** @see android.util.Log#w(String, String, Throwable) */
|
||||
@Pure
|
||||
public static void w(String tag, String message, @Nullable Throwable throwable) {
|
||||
w(tag, appendThrowableString(message, throwable));
|
||||
}
|
||||
|
||||
/** @see android.util.Log#e(String, String) */
|
||||
@Pure
|
||||
public static void e(String tag, String message) {
|
||||
if (logLevel <= LOG_LEVEL_ERROR) {
|
||||
android.util.Log.e(tag, message);
|
||||
@ -123,6 +133,7 @@ public final class Log {
|
||||
}
|
||||
|
||||
/** @see android.util.Log#e(String, String, Throwable) */
|
||||
@Pure
|
||||
public static void e(String tag, String message, @Nullable Throwable throwable) {
|
||||
e(tag, appendThrowableString(message, throwable));
|
||||
}
|
||||
@ -139,6 +150,7 @@ public final class Log {
|
||||
* @return The string representation of the {@link Throwable}.
|
||||
*/
|
||||
@Nullable
|
||||
@Pure
|
||||
public static String getThrowableString(@Nullable Throwable throwable) {
|
||||
if (throwable == null) {
|
||||
return null;
|
||||
@ -157,6 +169,7 @@ public final class Log {
|
||||
}
|
||||
}
|
||||
|
||||
@Pure
|
||||
private static String appendThrowableString(String message, @Nullable Throwable throwable) {
|
||||
@Nullable String throwableString = getThrowableString(throwable);
|
||||
if (!TextUtils.isEmpty(throwableString)) {
|
||||
@ -165,6 +178,7 @@ public final class Log {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Pure
|
||||
private static boolean isCausedByUnknownHostException(@Nullable Throwable throwable) {
|
||||
while (throwable != null) {
|
||||
if (throwable instanceof UnknownHostException) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user