mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-16 21:14:20 +01:00
Prevent error log interleaving
Between the calls to CONSOLE_ERR.print() and printStackTrace(CONSOLE_ERR), logs from other threads may be inserted. Synchronizing access to CONSOLE_ERR ensures that logs from different threads do not mix. PR #6487 <https://github.com/Genymobile/scrcpy/pull/6487> Signed-off-by: valord577 <valord577@gmail.com> Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
@@ -74,9 +74,11 @@ public final class Ln {
|
||||
public static void w(String message, Throwable throwable) {
|
||||
if (isEnabled(Level.WARN)) {
|
||||
Log.w(TAG, message, throwable);
|
||||
CONSOLE_ERR.print(PREFIX + "WARN: " + message + '\n');
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace(CONSOLE_ERR);
|
||||
synchronized (CONSOLE_ERR) {
|
||||
CONSOLE_ERR.print(PREFIX + "WARN: " + message + '\n');
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace(CONSOLE_ERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,9 +90,11 @@ public final class Ln {
|
||||
public static void e(String message, Throwable throwable) {
|
||||
if (isEnabled(Level.ERROR)) {
|
||||
Log.e(TAG, message, throwable);
|
||||
CONSOLE_ERR.print(PREFIX + "ERROR: " + message + '\n');
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace(CONSOLE_ERR);
|
||||
synchronized (CONSOLE_ERR) {
|
||||
CONSOLE_ERR.print(PREFIX + "ERROR: " + message + '\n');
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace(CONSOLE_ERR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user