@UnstableApi
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 = )
annotation Log.LogLevel

Log level for ExoPlayer logcat logging.

interface Log.Logger

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

Constants

const Int

Log level to log all messages.

const Int

Log level to only log error messages.

const Int

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

const Int
LOG_LEVEL_OFF = 2147483647

Log level to disable all logging.

const Int

Log level to only log warning and error messages.

Public functions

java-static String!
@Pure
appendThrowableString(message: String!, throwable: Throwable?)

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

java-static Unit
@Pure
d(tag: @Size(max = 23) String!, message: String!)

Logs a debug-level message.

java-static Unit
@Pure
d(tag: @Size(max = 23) String!, message: String!, throwable: Throwable?)

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

java-static Unit
@Pure
e(tag: @Size(max = 23) String!, message: String!)

Logs an error-level message.

java-static Unit
@Pure
e(tag: @Size(max = 23) String!, message: String!, throwable: Throwable?)

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

java-static String?

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

java-static Unit
@Pure
i(tag: @Size(max = 23) String!, message: String!)

Logs an information-level message.

java-static Unit
@Pure
i(tag: @Size(max = 23) String!, message: String!, throwable: Throwable?)

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

java-static Unit
setLogStackTraces(logStackTraces: Boolean)

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

java-static Unit

Sets a custom Logger as the output.

java-static Unit
@Pure
w(tag: @Size(max = 23) String!, message: String!)

Logs a warning-level message.

java-static Unit
@Pure
w(tag: @Size(max = 23) String!, message: String!, throwable: Throwable?)

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

Public properties

java-static Int
@GuardedBy(value = "lock")
logLevel

Constants

LOG_LEVEL_ALL

const val LOG_LEVEL_ALL = 0: Int

Log level to log all messages.

LOG_LEVEL_ERROR

const val LOG_LEVEL_ERROR = 3: Int

Log level to only log error messages.

LOG_LEVEL_INFO

const val LOG_LEVEL_INFO = 1: Int

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

LOG_LEVEL_OFF

const val LOG_LEVEL_OFF = 2147483647: Int

Log level to disable all logging.

LOG_LEVEL_WARNING

const val LOG_LEVEL_WARNING = 2: Int

Log level to only log warning and error messages.

Public functions

appendThrowableString

@Pure
java-static fun appendThrowableString(message: String!, throwable: Throwable?): String!

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

d

@Pure
java-static fun d(tag: @Size(max = 23) String!, message: String!): Unit

Logs a debug-level message.

Parameters
tag: @Size(max = 23) String!

The tag of the message.

message: String!

The message.

d

@Pure
java-static fun d(tag: @Size(max = 23) String!, message: String!, throwable: Throwable?): Unit

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

Parameters
tag: @Size(max = 23) String!

The tag of the message.

message: String!

The message.

throwable: Throwable?

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

e

@Pure
java-static fun e(tag: @Size(max = 23) String!, message: String!): Unit

Logs an error-level message.

Parameters
tag: @Size(max = 23) String!

The tag of the message.

message: String!

The message.

e

@Pure
java-static fun e(tag: @Size(max = 23) String!, message: String!, throwable: Throwable?): Unit

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

Parameters
tag: @Size(max = 23) String!

The tag of the message.

message: String!

The message.

throwable: Throwable?

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

getThrowableString

@Pure
java-static fun getThrowableString(throwable: Throwable?): String?

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
throwable: Throwable?

The Throwable.

Returns
String?

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

i

@Pure
java-static fun i(tag: @Size(max = 23) String!, message: String!): Unit

Logs an information-level message.

Parameters
tag: @Size(max = 23) String!

The tag of the message.

message: String!

The message.

i

@Pure
java-static fun i(tag: @Size(max = 23) String!, message: String!, throwable: Throwable?): Unit

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

Parameters
tag: @Size(max = 23) String!

The tag of the message.

message: String!

The message.

throwable: Throwable?

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

setLogStackTraces

java-static fun setLogStackTraces(logStackTraces: Boolean): Unit

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

Parameters
logStackTraces: Boolean

Whether stack traces will be logged.

setLogger

java-static fun setLogger(logger: Log.Logger!): Unit

Sets a custom Logger as the output.

Parameters
logger: Log.Logger!

The Logger.

w

@Pure
java-static fun w(tag: @Size(max = 23) String!, message: String!): Unit

Logs a warning-level message.

Parameters
tag: @Size(max = 23) String!

The tag of the message.

message: String!

The message.

w

@Pure
java-static fun w(tag: @Size(max = 23) String!, message: String!, throwable: Throwable?): Unit

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

Parameters
tag: @Size(max = 23) String!

The tag of the message.

message: String!

The message.

throwable: Throwable?

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

Public properties

logLevel

@GuardedBy(value = "lock")
java-static var logLevelInt