@UnstableApi
public final class Log


Wrapper around android.util.Log which allows to set the log level and to specify a custom log output.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
public annotation Log.LogLevel

Log level for ExoPlayer logcat logging.

public interface Log.Logger

Interface for a logger that can output messages with a tag.

Constants

static final int

Log level to log all messages.

static final int

Log level to only log error messages.

static final int

Log level to only log informative, warning and error messages.

static final int
LOG_LEVEL_OFF = 2147483647

Log level to disable all logging.

static final int

Log level to only log warning and error messages.

Public fields

static int
@GuardedBy(value = "lock")
logLevel

Public methods

static String

Appends the result of getThrowableString (if non-empty) to message.

static void
@Pure
d(@Size(max = 23) String tag, String message)

Logs a debug-level message.

static void
@Pure
d(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)

Logs a debug-level message with an optional associated Throwable.

static void
@Pure
e(@Size(max = 23) String tag, String message)

Logs an error-level message.

static void
@Pure
e(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)

Logs an error-level message with an optional associated Throwable.

static int

Returns current LogLevel for ExoPlayer logcat logging.

static @Nullable String

Returns a string representation of a Throwable suitable for logging, taking into account whether setLogStackTraces stack trace logging} is enabled.

static void
@Pure
i(@Size(max = 23) String tag, String message)

Logs an information-level message.

static void
@Pure
i(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)

Logs an information-level message with an optional associated Throwable.

static void
setLogLevel(@Log.LogLevel int logLevel)

Sets the LogLevel for ExoPlayer logcat logging.

static void
setLogStackTraces(boolean logStackTraces)

Sets whether stack traces of Throwables will be logged to logcat.

static void

Sets a custom Logger as the output.

static void
@Pure
w(@Size(max = 23) String tag, String message)

Logs a warning-level message.

static void
@Pure
w(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)

Logs a warning-level message with an optional associated Throwable..

Constants

LOG_LEVEL_ALL

public static final int LOG_LEVEL_ALL = 0

Log level to log all messages.

LOG_LEVEL_ERROR

public static final int LOG_LEVEL_ERROR = 3

Log level to only log error messages.

LOG_LEVEL_INFO

public static final int LOG_LEVEL_INFO = 1

Log level to only log informative, warning and error messages.

LOG_LEVEL_OFF

public static final int LOG_LEVEL_OFF = 2147483647

Log level to disable all logging.

LOG_LEVEL_WARNING

public static final int LOG_LEVEL_WARNING = 2

Log level to only log warning and error messages.

Public fields

logLevel

@GuardedBy(value = "lock")
public static int logLevel

Public methods

appendThrowableString

@Pure
public static String appendThrowableString(String message, @Nullable Throwable throwable)

Appends the result of getThrowableString (if non-empty) to message.

d

@Pure
public static void d(@Size(max = 23) String tag, String message)

Logs a debug-level message.

Parameters
@Size(max = 23) String tag

The tag of the message.

String message

The message.

d

@Pure
public static void d(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)

Logs a debug-level message with an optional associated Throwable.

Parameters
@Size(max = 23) String tag

The tag of the message.

String message

The message.

@Nullable Throwable throwable

The Throwable associated with the message, or null if not specified.

e

@Pure
public static void e(@Size(max = 23) String tag, String message)

Logs an error-level message.

Parameters
@Size(max = 23) String tag

The tag of the message.

String message

The message.

e

@Pure
public static void e(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)

Logs an error-level message with an optional associated Throwable.

Parameters
@Size(max = 23) String tag

The tag of the message.

String message

The message.

@Nullable Throwable throwable

The Throwable associated with the message, or null if not specified.

getLogLevel

@Pure
@Log.LogLevel
public static int getLogLevel()

Returns current LogLevel for ExoPlayer logcat logging.

getThrowableString

@Pure
public static @Nullable String getThrowableString(@Nullable Throwable throwable)

Returns a string representation of a Throwable suitable for logging, taking into account whether setLogStackTraces stack trace logging} is enabled.

Stack trace logging may be unconditionally suppressed for some expected failure modes (e.g., Throwables that are expected if the device doesn't have network connectivity) to avoid log spam.

Parameters
@Nullable Throwable throwable

The Throwable.

Returns
@Nullable String

The string representation of the Throwable, or null if throwable is null.

i

@Pure
public static void i(@Size(max = 23) String tag, String message)

Logs an information-level message.

Parameters
@Size(max = 23) String tag

The tag of the message.

String message

The message.

i

@Pure
public static void i(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)

Logs an information-level message with an optional associated Throwable.

Parameters
@Size(max = 23) String tag

The tag of the message.

String message

The message.

@Nullable Throwable throwable

The Throwable associated with the message, or null if not specified.

setLogLevel

public static void setLogLevel(@Log.LogLevel int logLevel)

Sets the LogLevel for ExoPlayer logcat logging.

Parameters
@Log.LogLevel int logLevel

The new LogLevel.

setLogStackTraces

public static void setLogStackTraces(boolean logStackTraces)

Sets whether stack traces of Throwables will be logged to logcat. Stack trace logging is enabled by default.

Parameters
boolean logStackTraces

Whether stack traces will be logged.

setLogger

public static void setLogger(Log.Logger logger)

Sets a custom Logger as the output.

Parameters
Log.Logger logger

The Logger.

w

@Pure
public static void w(@Size(max = 23) String tag, String message)

Logs a warning-level message.

Parameters
@Size(max = 23) String tag

The tag of the message.

String message

The message.

w

@Pure
public static void w(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)

Logs a warning-level message with an optional associated Throwable..

Parameters
@Size(max = 23) String tag

The tag of the message.

String message

The message.

@Nullable Throwable throwable

The Throwable associated with the message, or null if not specified.