public class

LoggingUtilsImpl

extends java.lang.Object

implements LoggingUtils

 java.lang.Object

↳androidx.wear.protolayout.renderer.common.LoggingUtilsImpl

Gradle dependencies

compile group: 'androidx.wear.protolayout', name: 'protolayout-renderer', version: '1.2.0'

  • groupId: androidx.wear.protolayout
  • artifactId: protolayout-renderer
  • version: 1.2.0

Artifact androidx.wear.protolayout:protolayout-renderer:1.2.0 it located at Google repository (https://maven.google.com/)

Overview

Logger used for extensive logging. Note that all logs will contain the component name. To enable logs use the following command:

   adb shell setprop log.tag.class_tag DEBUG
 

Summary

Constructors
publicLoggingUtilsImpl(ComponentName component)

Methods
public booleancanLogD(java.lang.String tag)

public voidlogD(java.lang.String tag, java.lang.String message)

public voidlogD(java.lang.String tag, java.lang.String format, java.lang.Object args[])

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public LoggingUtilsImpl(ComponentName component)

Methods

public void logD(java.lang.String tag, java.lang.String message)

public void logD(java.lang.String tag, java.lang.String format, java.lang.Object args[])

public boolean canLogD(java.lang.String tag)

Source

package androidx.wear.protolayout.renderer.common;

import android.content.ComponentName;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;

import com.google.errorprone.annotations.FormatMethod;
import com.google.errorprone.annotations.FormatString;

/**
 * Logger used for extensive logging. Note that all logs will contain the component name. To enable
 * logs use the following command:
 *
 * <pre>
 *   adb shell setprop log.tag.class_tag DEBUG
 * </pre>
 */
@RestrictTo(Scope.LIBRARY_GROUP_PREFIX)
public class LoggingUtilsImpl implements LoggingUtils {

    @NonNull private final ComponentName mComponent;

    public LoggingUtilsImpl(@NonNull ComponentName component) {
        this.mComponent = component;
    }

    @Override
    public void logD(@NonNull String tag, @NonNull String message) {
        logInternal(tag, message);
    }

    @Override
    @FormatMethod
    public void logD(
        @NonNull String tag,
        @NonNull @FormatString String format,
        @NonNull Object... args) {
        logD(tag, String.format(format, args));
    }

    private void logInternal(@NonNull String tag, @NonNull String message) {
        if (canLogD(tag)) {
            Log.d(tag, "Logs for: " + mComponent + "\n" + message);
        }
    }

    @Override
    public boolean canLogD(@NonNull String tag) {
        return Log.isLoggable(tag, Log.DEBUG);
    }
}