Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08e7e129 authored by Felipe Leme's avatar Felipe Leme
Browse files

Added Warning about extra object allocation on SLog methods.

Test: m
Bug: 182476140
Change-Id: Id210956dcc060f0570d1f5c95e11e0effc7d0d24
parent 9c907184
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -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;