This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
ExoPlayer 2 - Fix build by removing notils #45
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package com.novoda.utils; | ||
|
||
|
||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
|
||
public abstract class NoPlayerLog { | ||
|
||
private static final int DEPTH = 5; | ||
private static final int CLASS_SUFFIX = 5; | ||
|
||
private static boolean isEnabled = true; | ||
|
||
public static void setLoggingEnabled(boolean enabled) { | ||
isEnabled = enabled; | ||
} | ||
|
||
private static String logMessage(String message, Throwable throwable) { | ||
String detailedMessage = getDetailedLog(message); | ||
if (throwable != null) { | ||
detailedMessage += "\n" + getStackTraceString(throwable); | ||
} | ||
return detailedMessage; | ||
} | ||
|
||
private static String getDetailedLog(String message) { | ||
Thread current = Thread.currentThread(); | ||
final StackTraceElement trace = current.getStackTrace()[DEPTH]; | ||
final String filename = trace.getFileName(); | ||
return "[" + current.getName() + "][" + filename.substring(0, filename.length() - CLASS_SUFFIX) + "." | ||
+ trace.getMethodName() + ":" + trace.getLineNumber() + "] " + message; | ||
} | ||
|
||
private static String getStackTraceString(Throwable throwable) { | ||
|
||
StringWriter sw = new StringWriter(); | ||
PrintWriter pw = new PrintWriter(sw); | ||
try { | ||
throwable.printStackTrace(pw); | ||
return sw.toString().trim(); | ||
} finally { | ||
pw.close(); | ||
} | ||
} | ||
|
||
public static void d(String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.d("No-Player", logMessage(msg, null)); | ||
} | ||
|
||
public static void d(Throwable throwable, String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.d("No-Player", logMessage(msg, throwable)); | ||
} | ||
|
||
public static void e(String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.e("No-Player", logMessage(msg, null)); | ||
} | ||
|
||
public static void e(Throwable throwable, String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.e("No-Player", logMessage(msg, throwable)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit extract constant for the tag? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||
} | ||
|
||
public static void i(String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.i("No-Player", logMessage(msg, null)); | ||
} | ||
|
||
public static void i(Throwable throwable, String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.i("No-Player", logMessage(msg, throwable)); | ||
} | ||
|
||
public static void v(String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.v("No-Player", logMessage(msg, null)); | ||
} | ||
|
||
public static void v(Throwable throwable, String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.v("No-Player", logMessage(msg, throwable)); | ||
} | ||
|
||
public static void w(String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.w("No-Player", logMessage(msg, null)); | ||
} | ||
|
||
public static void w(Throwable throwable, String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.w("No-Player", logMessage(msg, throwable)); | ||
} | ||
|
||
public static void wtf(String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.wtf("No-Player", logMessage(msg, null)); | ||
} | ||
|
||
public static void wtf(Throwable throwable) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.wtf("No-Player", logMessage("", throwable)); | ||
} | ||
|
||
public static void wtf(Throwable throwable, String msg) { | ||
if (!isEnabled) { | ||
return; | ||
} | ||
android.util.Log.wtf("No-Player", logMessage(msg, throwable)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically a quick port of what we have in
notils