Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fc952bfb
authored
Jan 19, 2021
by
ibaker
Committed by
Oliver Woodman
Jan 19, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Annotate log methods with @Pure
PiperOrigin-RevId: 352519583
parent
0c22810a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/Log.java
library/common/src/main/java/com/google/android/exoplayer2/util/Log.java
View file @
fc952bfb
...
...
@@ -22,6 +22,7 @@ import java.lang.annotation.Documented;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.net.UnknownHostException
;
import
org.checkerframework.dataflow.qual.Pure
;
/** Wrapper around {@link android.util.Log} which allows to set the log level. */
public
final
class
Log
{
...
...
@@ -51,11 +52,13 @@ public final class Log {
private
Log
()
{}
/** Returns current {@link LogLevel} for ExoPlayer logcat logging. */
@Pure
public
static
@LogLevel
int
getLogLevel
()
{
return
logLevel
;
}
/** Returns whether stack traces of {@link Throwable}s will be logged to logcat. */
@Pure
public
boolean
getLogStackTraces
()
{
return
logStackTraces
;
}
...
...
@@ -80,6 +83,7 @@ public final class Log {
}
/** @see android.util.Log#d(String, String) */
@Pure
public
static
void
d
(
String
tag
,
String
message
)
{
if
(
logLevel
==
LOG_LEVEL_ALL
)
{
android
.
util
.
Log
.
d
(
tag
,
message
);
...
...
@@ -87,11 +91,13 @@ public final class Log {
}
/** @see android.util.Log#d(String, String, Throwable) */
@Pure
public
static
void
d
(
String
tag
,
String
message
,
@Nullable
Throwable
throwable
)
{
d
(
tag
,
appendThrowableString
(
message
,
throwable
));
}
/** @see android.util.Log#i(String, String) */
@Pure
public
static
void
i
(
String
tag
,
String
message
)
{
if
(
logLevel
<=
LOG_LEVEL_INFO
)
{
android
.
util
.
Log
.
i
(
tag
,
message
);
...
...
@@ -99,11 +105,13 @@ public final class Log {
}
/** @see android.util.Log#i(String, String, Throwable) */
@Pure
public
static
void
i
(
String
tag
,
String
message
,
@Nullable
Throwable
throwable
)
{
i
(
tag
,
appendThrowableString
(
message
,
throwable
));
}
/** @see android.util.Log#w(String, String) */
@Pure
public
static
void
w
(
String
tag
,
String
message
)
{
if
(
logLevel
<=
LOG_LEVEL_WARNING
)
{
android
.
util
.
Log
.
w
(
tag
,
message
);
...
...
@@ -111,11 +119,13 @@ public final class Log {
}
/** @see android.util.Log#w(String, String, Throwable) */
@Pure
public
static
void
w
(
String
tag
,
String
message
,
@Nullable
Throwable
throwable
)
{
w
(
tag
,
appendThrowableString
(
message
,
throwable
));
}
/** @see android.util.Log#e(String, String) */
@Pure
public
static
void
e
(
String
tag
,
String
message
)
{
if
(
logLevel
<=
LOG_LEVEL_ERROR
)
{
android
.
util
.
Log
.
e
(
tag
,
message
);
...
...
@@ -123,6 +133,7 @@ public final class Log {
}
/** @see android.util.Log#e(String, String, Throwable) */
@Pure
public
static
void
e
(
String
tag
,
String
message
,
@Nullable
Throwable
throwable
)
{
e
(
tag
,
appendThrowableString
(
message
,
throwable
));
}
...
...
@@ -139,6 +150,7 @@ public final class Log {
* @return The string representation of the {@link Throwable}.
*/
@Nullable
@Pure
public
static
String
getThrowableString
(
@Nullable
Throwable
throwable
)
{
if
(
throwable
==
null
)
{
return
null
;
...
...
@@ -157,6 +169,7 @@ public final class Log {
}
}
@Pure
private
static
String
appendThrowableString
(
String
message
,
@Nullable
Throwable
throwable
)
{
@Nullable
String
throwableString
=
getThrowableString
(
throwable
);
if
(!
TextUtils
.
isEmpty
(
throwableString
))
{
...
...
@@ -165,6 +178,7 @@ public final class Log {
return
message
;
}
@Pure
private
static
boolean
isCausedByUnknownHostException
(
@Nullable
Throwable
throwable
)
{
while
(
throwable
!=
null
)
{
if
(
throwable
instanceof
UnknownHostException
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment