Loading core/java/android/util/Slog.java +0 −173 Original line number Diff line number Diff line Loading @@ -16,15 +16,9 @@ package android.util; import android.annotation.Nullable; import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; import com.android.internal.annotations.GuardedBy; import java.util.Formatter; import java.util.Locale; /** * API for sending log output to the {@link Log#LOG_ID_SYSTEM} buffer. * Loading @@ -34,12 +28,6 @@ import java.util.Locale; */ public final class Slog { @GuardedBy("Slog.class") private static StringBuilder sMessageBuilder; @GuardedBy("Slog.class") private static Formatter sFormatter; private Slog() { } Loading @@ -53,24 +41,6 @@ public final class Slog { msg + '\n' + Log.getStackTraceString(tr)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void v(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.VERBOSE)) return; v(tag, getMessage(format, args)); } @UnsupportedAppUsage public static int d(String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, Log.DEBUG, tag, msg); Loading @@ -82,24 +52,6 @@ public final class Slog { msg + '\n' + Log.getStackTraceString(tr)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void d(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.DEBUG)) return; d(tag, getMessage(format, args)); } @UnsupportedAppUsage public static int i(String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, Log.INFO, tag, msg); Loading @@ -110,24 +62,6 @@ public final class Slog { msg + '\n' + Log.getStackTraceString(tr)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void i(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.INFO)) return; i(tag, getMessage(format, args)); } @UnsupportedAppUsage public static int w(String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, Log.WARN, tag, msg); Loading @@ -143,42 +77,6 @@ public final class Slog { return Log.println_native(Log.LOG_ID_SYSTEM, Log.WARN, tag, Log.getStackTraceString(tr)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void w(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.WARN)) return; w(tag, getMessage(format, args)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void w(String tag, Exception exception, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.WARN)) return; w(tag, getMessage(format, args), exception); } @UnsupportedAppUsage public static int e(String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, Log.ERROR, tag, msg); Loading @@ -190,42 +88,6 @@ public final class Slog { msg + '\n' + Log.getStackTraceString(tr)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void e(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.ERROR)) return; e(tag, getMessage(format, args)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void e(String tag, Exception exception, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.ERROR)) return; e(tag, getMessage(format, args), exception); } /** * Like {@link Log#wtf(String, String)}, but will never cause the caller to crash, and * will always be handled asynchronously. Primarily for use by coding running within Loading @@ -236,27 +98,6 @@ public final class Slog { return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false, true); } /** * Logs a {@code wtf} message. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void wtf(String tag, String format, @Nullable Object... args) { wtf(tag, getMessage(format, args)); } /** * Logs a {@code wtf} message with an exception. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void wtf(String tag, Exception exception, String format, @Nullable Object... args) { wtf(tag, getMessage(format, args), exception); } /** * Like {@link #wtf(String, String)}, but does not output anything to the log. */ Loading Loading @@ -297,18 +138,4 @@ public final class Slog { public static int println(int priority, String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, priority, tag, msg); } private static String getMessage(String format, @Nullable Object... args) { synchronized (Slog.class) { if (sMessageBuilder == null) { // Lazy load so they're not created if not used by the process sMessageBuilder = new StringBuilder(); sFormatter = new Formatter(sMessageBuilder, Locale.ENGLISH); } sFormatter.format(format, args); String message = sMessageBuilder.toString(); sMessageBuilder.setLength(0); return message; } } } Loading
core/java/android/util/Slog.java +0 −173 Original line number Diff line number Diff line Loading @@ -16,15 +16,9 @@ package android.util; import android.annotation.Nullable; import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; import com.android.internal.annotations.GuardedBy; import java.util.Formatter; import java.util.Locale; /** * API for sending log output to the {@link Log#LOG_ID_SYSTEM} buffer. * Loading @@ -34,12 +28,6 @@ import java.util.Locale; */ public final class Slog { @GuardedBy("Slog.class") private static StringBuilder sMessageBuilder; @GuardedBy("Slog.class") private static Formatter sFormatter; private Slog() { } Loading @@ -53,24 +41,6 @@ public final class Slog { msg + '\n' + Log.getStackTraceString(tr)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void v(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.VERBOSE)) return; v(tag, getMessage(format, args)); } @UnsupportedAppUsage public static int d(String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, Log.DEBUG, tag, msg); Loading @@ -82,24 +52,6 @@ public final class Slog { msg + '\n' + Log.getStackTraceString(tr)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void d(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.DEBUG)) return; d(tag, getMessage(format, args)); } @UnsupportedAppUsage public static int i(String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, Log.INFO, tag, msg); Loading @@ -110,24 +62,6 @@ public final class Slog { msg + '\n' + Log.getStackTraceString(tr)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void i(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.INFO)) return; i(tag, getMessage(format, args)); } @UnsupportedAppUsage public static int w(String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, Log.WARN, tag, msg); Loading @@ -143,42 +77,6 @@ public final class Slog { return Log.println_native(Log.LOG_ID_SYSTEM, Log.WARN, tag, Log.getStackTraceString(tr)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void w(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.WARN)) return; w(tag, getMessage(format, args)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void w(String tag, Exception exception, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.WARN)) return; w(tag, getMessage(format, args), exception); } @UnsupportedAppUsage public static int e(String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, Log.ERROR, tag, msg); Loading @@ -190,42 +88,6 @@ public final class Slog { msg + '\n' + Log.getStackTraceString(tr)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void e(String tag, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.ERROR)) return; e(tag, getMessage(format, args)); } /** * 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. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void e(String tag, Exception exception, String format, @Nullable Object... args) { if (!Log.isLoggable(tag, Log.ERROR)) return; e(tag, getMessage(format, args), exception); } /** * Like {@link Log#wtf(String, String)}, but will never cause the caller to crash, and * will always be handled asynchronously. Primarily for use by coding running within Loading @@ -236,27 +98,6 @@ public final class Slog { return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false, true); } /** * Logs a {@code wtf} message. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void wtf(String tag, String format, @Nullable Object... args) { wtf(tag, getMessage(format, args)); } /** * Logs a {@code wtf} message with an exception. * * @deprecated use {@code com.android.server.utils.SLogF} instead. */ @Deprecated public static void wtf(String tag, Exception exception, String format, @Nullable Object... args) { wtf(tag, getMessage(format, args), exception); } /** * Like {@link #wtf(String, String)}, but does not output anything to the log. */ Loading Loading @@ -297,18 +138,4 @@ public final class Slog { public static int println(int priority, String tag, String msg) { return Log.println_native(Log.LOG_ID_SYSTEM, priority, tag, msg); } private static String getMessage(String format, @Nullable Object... args) { synchronized (Slog.class) { if (sMessageBuilder == null) { // Lazy load so they're not created if not used by the process sMessageBuilder = new StringBuilder(); sFormatter = new Formatter(sMessageBuilder, Locale.ENGLISH); } sFormatter.format(format, args); String message = sMessageBuilder.toString(); sMessageBuilder.setLength(0); return message; } } }