Log to android logger and stdout/stderr
This commit is contained in:
parent
95591d2938
commit
6605ab8e23
2 changed files with 40 additions and 2 deletions
37
server/src/com/genymobile/scrcpy/Ln.java
Normal file
37
server/src/com/genymobile/scrcpy/Ln.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package com.genymobile.scrcpy;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log both to Android logger (so that logs are visible in "adb logcat") and standard output/error (so that they are visible in the terminal
|
||||||
|
* directly).
|
||||||
|
*/
|
||||||
|
public class Ln {
|
||||||
|
|
||||||
|
private static final String TAG = "scrcpy";
|
||||||
|
|
||||||
|
private Ln() {
|
||||||
|
// not instantiable
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void d(String message) {
|
||||||
|
Log.d(TAG, message);
|
||||||
|
System.out.println("DEBUG: " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void i(String message) {
|
||||||
|
Log.i(TAG, message);
|
||||||
|
System.out.println("INFO: " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void w(String message) {
|
||||||
|
Log.w(TAG, message);
|
||||||
|
System.out.println("WARN: " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void e(String message, Throwable throwable) {
|
||||||
|
Log.e(TAG, message, throwable);
|
||||||
|
System.out.println("ERROR: " + message);
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class ScrCpyServer {
|
public class ScrCpyServer {
|
||||||
|
|
||||||
|
private static final String TAG = "scrcpy";
|
||||||
|
|
||||||
public static void scrcpy() throws IOException {
|
public static void scrcpy() throws IOException {
|
||||||
String deviceName = DeviceUtil.getDeviceName();
|
String deviceName = DeviceUtil.getDeviceName();
|
||||||
ScreenInfo initialScreenInfo = DeviceUtil.getScreenInfo();
|
ScreenInfo initialScreenInfo = DeviceUtil.getScreenInfo();
|
||||||
|
@ -13,8 +15,7 @@ public class ScrCpyServer {
|
||||||
try {
|
try {
|
||||||
new ScreenStreamer(connection).streamScreen();
|
new ScreenStreamer(connection).streamScreen();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Screen streaming interrupted: " + e.getMessage());
|
Ln.e("Screen streaming interrupted", e);
|
||||||
System.err.flush();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue