diff options
| -rw-r--r-- | core/java/android/util/Slog.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/core/java/android/util/Slog.java b/core/java/android/util/Slog.java index f61ab2985163..b949ea3262c6 100644 --- a/core/java/android/util/Slog.java +++ b/core/java/android/util/Slog.java @@ -51,6 +51,12 @@ public final class Slog { /** * Logs a {@link Log.VERBOSE} message. + * + * <p><strong>Note: </strong>the message will only be formatted if {@link Log#WARN} logging is + * enabled for the given {@code tag}, but the compiler will still create an intermediate array + * of the objects for the {@code vargars}, which could affect garbage collection. So, if you're + * calling this method in a critical path, make sure to explicitly do the check before calling + * it. */ public static void v(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.VERBOSE)) return; @@ -71,6 +77,12 @@ public final class Slog { /** * Logs a {@link Log.DEBUG} message. + * + * <p><strong>Note: </strong>the message will only be formatted if {@link Log#WARN} logging is + * enabled for the given {@code tag}, but the compiler will still create an intermediate array + * of the objects for the {@code vargars}, which could affect garbage collection. So, if you're + * calling this method in a critical path, make sure to explicitly do the check before calling + * it. */ public static void d(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.DEBUG)) return; @@ -90,6 +102,12 @@ public final class Slog { /** * Logs a {@link Log.INFO} message. + * + * <p><strong>Note: </strong>the message will only be formatted if {@link Log#WARN} logging is + * enabled for the given {@code tag}, but the compiler will still create an intermediate array + * of the objects for the {@code vargars}, which could affect garbage collection. So, if you're + * calling this method in a critical path, make sure to explicitly do the check before calling + * it. */ public static void i(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.INFO)) return; @@ -114,6 +132,12 @@ public final class Slog { /** * Logs a {@link Log.WARN} message. + * + * <p><strong>Note: </strong>the message will only be formatted if {@link Log#WARN} logging is + * enabled for the given {@code tag}, but the compiler will still create an intermediate array + * of the objects for the {@code vargars}, which could affect garbage collection. So, if you're + * calling this method in a critical path, make sure to explicitly do the check before calling + * it. */ public static void w(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.WARN)) return; @@ -123,6 +147,12 @@ public final class Slog { /** * Logs a {@link Log.WARN} message with an exception + * + * <p><strong>Note: </strong>the message will only be formatted if {@link Log#WARN} logging is + * enabled for the given {@code tag}, but the compiler will still create an intermediate array + * of the objects for the {@code vargars}, which could affect garbage collection. So, if you're + * calling this method in a critical path, make sure to explicitly do the check before calling + * it. */ public static void w(String tag, Exception exception, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.WARN)) return; @@ -143,6 +173,12 @@ public final class Slog { /** * Logs a {@link Log.ERROR} message. + * + * <p><strong>Note: </strong>the message will only be formatted if {@link Log#WARN} logging is + * enabled for the given {@code tag}, but the compiler will still create an intermediate array + * of the objects for the {@code vargars}, which could affect garbage collection. So, if you're + * calling this method in a critical path, make sure to explicitly do the check before calling + * it. */ public static void e(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.ERROR)) return; @@ -152,6 +188,12 @@ public final class Slog { /** * Logs a {@link Log.ERROR} message with an exception + * + * <p><strong>Note: </strong>the message will only be formatted if {@link Log#WARN} logging is + * enabled for the given {@code tag}, but the compiler will still create an intermediate array + * of the objects for the {@code vargars}, which could affect garbage collection. So, if you're + * calling this method in a critical path, make sure to explicitly do the check before calling + * it. */ public static void e(String tag, Exception exception, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.ERROR)) return; |