Log
@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 |
|---|
@DocumentedLog level for ExoPlayer logcat logging. |
public interface Log.LoggerInterface for a logger that can output messages with a tag. |
Constants |
|
|---|---|
static final int |
LOG_LEVEL_ALL = 0Log level to log all messages. |
static final int |
LOG_LEVEL_ERROR = 3Log level to only log error messages. |
static final int |
LOG_LEVEL_INFO = 1Log level to only log informative, warning and error messages. |
static final int |
LOG_LEVEL_OFF = 2147483647Log level to disable all logging. |
static final int |
Log level to only log warning and error messages. |
Public methods |
|
|---|---|
static String |
@PureAppends the result of |
static void |
Logs a debug-level message. |
static void |
Logs a debug-level message with an optional associated |
static void |
Logs an error-level message. |
static void |
Logs an error-level message with an optional associated |
static int |
Returns current |
static @Nullable String |
@PureReturns a string representation of a |
static void |
Logs an information-level message. |
static void |
Logs an information-level message with an optional associated |
static void |
setLogLevel(@Log.LogLevel int logLevel)Sets the |
static void |
setLogStackTraces(boolean logStackTraces)Sets whether stack traces of |
static void |
setLogger(Log.Logger logger)Sets a custom |
static void |
Logs a warning-level message. |
static void |
Logs a warning-level message with an optional associated |
Constants
LOG_LEVEL_INFO
public static final int LOG_LEVEL_INFO = 1
Log level to only log informative, warning and error messages.
LOG_LEVEL_WARNING
public static final int LOG_LEVEL_WARNING = 2
Log level to only log warning and error messages.
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, @Nullable Throwable throwable)
Logs a debug-level message with an optional associated Throwable.
e
@Pure
public static void e(@Size(max = 23) String tag, String message)
Logs an error-level 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.
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.
i
@Pure
public static void i(@Size(max = 23) String tag, String message)
Logs an information-level 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.
setLogLevel
public static void setLogLevel(@Log.LogLevel int logLevel)
Sets the LogLevel for ExoPlayer logcat logging.
| Parameters | |
|---|---|
@Log.LogLevel int logLevel |
The new |
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 |
w
@Pure
public static void w(@Size(max = 23) String tag, String message)
Logs a warning-level message.