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
c761538c
authored
Apr 12, 2022
by
Shashikant
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Route the logs to custom logger
parent
8e57d371
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/CustomLogger.java
library/common/src/main/java/com/google/android/exoplayer2/util/Log.java
library/common/src/main/java/com/google/android/exoplayer2/util/CustomLogger.java
0 → 100644
View file @
c761538c
package
com
.
google
.
android
.
exoplayer2
.
util
;
/**
* Interface to be implemented by a custom logger if logging required is other than simple {@link android.util.Log}
* <p>
* {@link Log.setCustomLogger(CustomLogger)} should be used to provide the implementation
*/
public
interface
CustomLogger
{
/**
* Analogous to {@link android.util.Log#d(String, String)}
*
* @see android.util.Log#d(String, String)
*/
void
d
(
String
tag
,
String
message
);
/**
* Analogous to {@link android.util.Log#i(String, String)}
*
* @see android.util.Log#i(String, String)
*/
void
i
(
String
tag
,
String
message
);
/**
* Analogous to {@link android.util.Log#w(String, String)}
*
* @see android.util.Log#w(String, String)
*/
void
w
(
String
tag
,
String
message
);
/**
* Analogous to {@link android.util.Log#e(String, String)}
*
* @see android.util.Log#e(String, String)
*/
void
e
(
String
tag
,
String
message
);
}
library/common/src/main/java/com/google/android/exoplayer2/util/Log.java
View file @
c761538c
...
...
@@ -72,6 +72,16 @@ public final class Log {
}
/**
* Sets a custom logger for the ExoPlayer logs.
* Logs are routed to this logger once this is initialized.
*
* @param customLogger - a {@link CustomLogger} implementation
*/
public
static
void
setCustomLogger
(
@Nullable
CustomLogger
customLogger
)
{
Log
.
customLogger
=
customLogger
;
}
/**
* Sets whether stack traces of {@link Throwable}s will be logged to logcat. Stack trace logging
* is enabled by default.
*
...
...
@@ -87,6 +97,9 @@ public final class Log {
@Pure
public
static
void
d
(
@Size
(
max
=
23
)
String
tag
,
String
message
)
{
if
(
logLevel
==
LOG_LEVEL_ALL
)
{
if
(
customLogger
!=
null
)
{
customLogger
.
d
(
tag
,
message
);
}
android
.
util
.
Log
.
d
(
tag
,
message
);
}
}
...
...
@@ -105,6 +118,9 @@ public final class Log {
@Pure
public
static
void
i
(
@Size
(
max
=
23
)
String
tag
,
String
message
)
{
if
(
logLevel
<=
LOG_LEVEL_INFO
)
{
if
(
customLogger
!=
null
)
{
customLogger
.
i
(
tag
,
message
);
}
android
.
util
.
Log
.
i
(
tag
,
message
);
}
}
...
...
@@ -123,6 +139,9 @@ public final class Log {
@Pure
public
static
void
w
(
@Size
(
max
=
23
)
String
tag
,
String
message
)
{
if
(
logLevel
<=
LOG_LEVEL_WARNING
)
{
if
(
customLogger
!=
null
)
{
customLogger
.
w
(
tag
,
message
);
}
android
.
util
.
Log
.
w
(
tag
,
message
);
}
}
...
...
@@ -141,6 +160,9 @@ public final class Log {
@Pure
public
static
void
e
(
@Size
(
max
=
23
)
String
tag
,
String
message
)
{
if
(
logLevel
<=
LOG_LEVEL_ERROR
)
{
if
(
customLogger
!=
null
)
{
customLogger
.
e
(
tag
,
message
);
}
android
.
util
.
Log
.
e
(
tag
,
message
);
}
}
...
...
@@ -203,4 +225,5 @@ public final class Log {
}
return
false
;
}
}
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