From bb56472d4eb15d7c318a05a8236af6d0f5a46a04 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 8 Mar 2023 20:07:03 +0100 Subject: [PATCH] Print server logs and newline in one call System.out.println() first prints the message, then the new line. Between these two calls, the client might print a message, breaking formatting. Instead, call System.out.print() with '\n' appended to the message. --- server/src/main/java/com/genymobile/scrcpy/Ln.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/Ln.java b/server/src/main/java/com/genymobile/scrcpy/Ln.java index c39fc621..291f26ff 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Ln.java +++ b/server/src/main/java/com/genymobile/scrcpy/Ln.java @@ -39,28 +39,28 @@ public final class Ln { public static void v(String message) { if (isEnabled(Level.VERBOSE)) { Log.v(TAG, message); - System.out.println(PREFIX + "VERBOSE: " + message); + System.out.print(PREFIX + "VERBOSE: " + message + '\n'); } } public static void d(String message) { if (isEnabled(Level.DEBUG)) { Log.d(TAG, message); - System.out.println(PREFIX + "DEBUG: " + message); + System.out.print(PREFIX + "DEBUG: " + message + '\n'); } } public static void i(String message) { if (isEnabled(Level.INFO)) { Log.i(TAG, message); - System.out.println(PREFIX + "INFO: " + message); + System.out.print(PREFIX + "INFO: " + message + '\n'); } } public static void w(String message, Throwable throwable) { if (isEnabled(Level.WARN)) { Log.w(TAG, message, throwable); - System.out.println(PREFIX + "WARN: " + message); + System.out.print(PREFIX + "WARN: " + message + '\n'); if (throwable != null) { throwable.printStackTrace(); } @@ -74,7 +74,7 @@ public final class Ln { public static void e(String message, Throwable throwable) { if (isEnabled(Level.ERROR)) { Log.e(TAG, message, throwable); - System.out.println(PREFIX + "ERROR: " + message); + System.out.print(PREFIX + "ERROR: " + message + "\n"); if (throwable != null) { throwable.printStackTrace(); }