Logger

@RequiresApi(21) class Logger
kotlin.Any
   ↳ androidx.camera.previewview.internal.utils.Logger

Handles logging requests inside CameraX. Log messages are output only if: - The minimum logging level allows for it. The minimum logging level is set via setMinLogLevel(int), which should typically be called during the process of configuring CameraX. - The log tag is loggable. This can be configured by setting the system property `setprop log.tag.TAG LEVEL`, where TAG is the log tag, and LEVEL is Log#DEBUG, Log#INFO, Log#WARN or Log#ERROR.

A typical usage of the Logger looks as follows:

try {
          int quotient = dividend / divisor;
      } catch (ArithmeticException exception) {
          Logger.e(TAG, "Divide operation error", exception);
      }
  

If an action has to be performed alongside logging, or if building the log message is costly, perform a log level check before attempting to log.

try {
          int quotient = dividend / divisor;
      } catch (ArithmeticException exception) {
          if (Logger.isErrorEnabled(TAG)) {
              Logger.e(TAG, "Divide operation error", exception);
              doSomething();
          }
      }
  

Summary

Public methods
static Unit
d(@NonNull tag: String, @NonNull message: String)

Logs the given Log#DEBUG message if the tag is loggable.

static Unit
d(@NonNull tag: String, @NonNull message: String, @NonNull throwable: Throwable)

Logs the given Log#DEBUG message and the exception's stacktrace if the tag is loggable.

static Unit
e(@NonNull tag: String, @NonNull message: String)

Logs the given Log#ERROR message if the tag is loggable.

static Unit
e(@NonNull tag: String, @NonNull message: String, @NonNull throwable: Throwable)

Logs the given Log#ERROR message and the exception's stacktrace if the tag is loggable.

static Unit
i(@NonNull tag: String, @NonNull message: String)

Logs the given Log#INFO message if the tag is loggable.

static Unit
i(@NonNull tag: String, @NonNull message: String, @NonNull throwable: Throwable)

Logs the given Log#INFO message and the exception's stacktrace if the tag is loggable.

static Boolean
isDebugEnabled(@NonNull tag: String)

Returns true if logging with the tag tag is enabled at the Log#DEBUG level.

static Boolean
isErrorEnabled(@NonNull tag: String)

Returns true if logging with the tag tag is enabled at the Log#ERROR level.

static Boolean
isInfoEnabled(@NonNull tag: String)

Returns true if logging with the tag tag is enabled at the Log#INFO level.

static Boolean
isWarnEnabled(@NonNull tag: String)

Returns true if logging with the tag tag is enabled at the Log#WARN level.

static Unit
w(@NonNull tag: String, @NonNull message: String)

Logs the given Log#WARN message if the tag is loggable.

static Unit
w(@NonNull tag: String, @NonNull message: String, @NonNull throwable: Throwable)

Logs the given Log#WARN message and the exception's stacktrace if the tag is loggable.

Public methods

d

static fun d(
    @NonNull tag: String,
    @NonNull message: String
): Unit

Logs the given Log#DEBUG message if the tag is loggable.

d

static fun d(
    @NonNull tag: String,
    @NonNull message: String,
    @NonNull throwable: Throwable
): Unit

Logs the given Log#DEBUG message and the exception's stacktrace if the tag is loggable.

e

static fun e(
    @NonNull tag: String,
    @NonNull message: String
): Unit

Logs the given Log#ERROR message if the tag is loggable.

e

static fun e(
    @NonNull tag: String,
    @NonNull message: String,
    @NonNull throwable: Throwable
): Unit

Logs the given Log#ERROR message and the exception's stacktrace if the tag is loggable.

i

static fun i(
    @NonNull tag: String,
    @NonNull message: String
): Unit

Logs the given Log#INFO message if the tag is loggable.

i

static fun i(
    @NonNull tag: String,
    @NonNull message: String,
    @NonNull throwable: Throwable
): Unit

Logs the given Log#INFO message and the exception's stacktrace if the tag is loggable.

isDebugEnabled

static fun isDebugEnabled(@NonNull tag: String): Boolean

Returns true if logging with the tag tag is enabled at the Log#DEBUG level. This is true when the minimum logging level is less than or equal to Log#DEBUG, or if the log level of tag was explicitly set to Log#DEBUG at least.

isErrorEnabled

static fun isErrorEnabled(@NonNull tag: String): Boolean

Returns true if logging with the tag tag is enabled at the Log#ERROR level. This is true when the minimum logging level is less than or equal to Log#ERROR, or if the log level of tag was explicitly set to Log#ERROR at least.

isInfoEnabled

static fun isInfoEnabled(@NonNull tag: String): Boolean

Returns true if logging with the tag tag is enabled at the Log#INFO level. This is true when the minimum logging level is less than or equal to Log#INFO, or if the log level of tag was explicitly set to Log#INFO at least.

isWarnEnabled

static fun isWarnEnabled(@NonNull tag: String): Boolean

Returns true if logging with the tag tag is enabled at the Log#WARN level. This is true when the minimum logging level is less than or equal to Log#WARN, or if the log level of tag was explicitly set to Log#WARN at least.

w

static fun w(
    @NonNull tag: String,
    @NonNull message: String
): Unit

Logs the given Log#WARN message if the tag is loggable.

w

static fun w(
    @NonNull tag: String,
    @NonNull message: String,
    @NonNull throwable: Throwable
): Unit

Logs the given Log#WARN message and the exception's stacktrace if the tag is loggable.