Configure server verbosity from the client
Send the requested log level from the client. This paves the way to configure it via a command-line argument.
This commit is contained in:
parent
56bff2f718
commit
3df63c579d
4 changed files with 45 additions and 14 deletions
|
@ -259,6 +259,11 @@ execute_server(struct server *server, const struct server_params *params) {
|
||||||
"/", // unused
|
"/", // unused
|
||||||
"com.genymobile.scrcpy.Server",
|
"com.genymobile.scrcpy.Server",
|
||||||
SCRCPY_VERSION,
|
SCRCPY_VERSION,
|
||||||
|
#ifndef NDEBUG
|
||||||
|
"debug",
|
||||||
|
#else
|
||||||
|
"info",
|
||||||
|
#endif
|
||||||
max_size_string,
|
max_size_string,
|
||||||
bit_rate_string,
|
bit_rate_string,
|
||||||
max_fps_string,
|
max_fps_string,
|
||||||
|
|
|
@ -15,12 +15,23 @@ public final class Ln {
|
||||||
DEBUG, INFO, WARN, ERROR
|
DEBUG, INFO, WARN, ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Level THRESHOLD = BuildConfig.DEBUG ? Level.DEBUG : Level.INFO;
|
private static Level THRESHOLD;
|
||||||
|
|
||||||
private Ln() {
|
private Ln() {
|
||||||
// not instantiable
|
// not instantiable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the log level.
|
||||||
|
* <p>
|
||||||
|
* Must be called before starting any new thread.
|
||||||
|
*
|
||||||
|
* @param level the log level
|
||||||
|
*/
|
||||||
|
public static void initLogLevel(Level level) {
|
||||||
|
THRESHOLD = level;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isEnabled(Level level) {
|
public static boolean isEnabled(Level level) {
|
||||||
return level.ordinal() >= THRESHOLD.ordinal();
|
return level.ordinal() >= THRESHOLD.ordinal();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.genymobile.scrcpy;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
|
||||||
public class Options {
|
public class Options {
|
||||||
|
private Ln.Level logLevel;
|
||||||
private int maxSize;
|
private int maxSize;
|
||||||
private int bitRate;
|
private int bitRate;
|
||||||
private int maxFps;
|
private int maxFps;
|
||||||
|
@ -16,6 +17,14 @@ public class Options {
|
||||||
private boolean stayAwake;
|
private boolean stayAwake;
|
||||||
private String codecOptions;
|
private String codecOptions;
|
||||||
|
|
||||||
|
public Ln.Level getLogLevel() {
|
||||||
|
return logLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogLevel(Ln.Level logLevel) {
|
||||||
|
this.logLevel = logLevel;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMaxSize() {
|
public int getMaxSize() {
|
||||||
return maxSize;
|
return maxSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,48 +119,51 @@ public final class Server {
|
||||||
"The server version (" + BuildConfig.VERSION_NAME + ") does not match the client " + "(" + clientVersion + ")");
|
"The server version (" + BuildConfig.VERSION_NAME + ") does not match the client " + "(" + clientVersion + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
final int expectedParameters = 13;
|
final int expectedParameters = 14;
|
||||||
if (args.length != expectedParameters) {
|
if (args.length != expectedParameters) {
|
||||||
throw new IllegalArgumentException("Expecting " + expectedParameters + " parameters");
|
throw new IllegalArgumentException("Expecting " + expectedParameters + " parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
int maxSize = Integer.parseInt(args[1]) & ~7; // multiple of 8
|
Ln.Level level = Ln.Level.valueOf(args[1].toUpperCase());
|
||||||
|
options.setLogLevel(level);
|
||||||
|
|
||||||
|
int maxSize = Integer.parseInt(args[2]) & ~7; // multiple of 8
|
||||||
options.setMaxSize(maxSize);
|
options.setMaxSize(maxSize);
|
||||||
|
|
||||||
int bitRate = Integer.parseInt(args[2]);
|
int bitRate = Integer.parseInt(args[3]);
|
||||||
options.setBitRate(bitRate);
|
options.setBitRate(bitRate);
|
||||||
|
|
||||||
int maxFps = Integer.parseInt(args[3]);
|
int maxFps = Integer.parseInt(args[4]);
|
||||||
options.setMaxFps(maxFps);
|
options.setMaxFps(maxFps);
|
||||||
|
|
||||||
int lockedVideoOrientation = Integer.parseInt(args[4]);
|
int lockedVideoOrientation = Integer.parseInt(args[5]);
|
||||||
options.setLockedVideoOrientation(lockedVideoOrientation);
|
options.setLockedVideoOrientation(lockedVideoOrientation);
|
||||||
|
|
||||||
// use "adb forward" instead of "adb tunnel"? (so the server must listen)
|
// use "adb forward" instead of "adb tunnel"? (so the server must listen)
|
||||||
boolean tunnelForward = Boolean.parseBoolean(args[5]);
|
boolean tunnelForward = Boolean.parseBoolean(args[6]);
|
||||||
options.setTunnelForward(tunnelForward);
|
options.setTunnelForward(tunnelForward);
|
||||||
|
|
||||||
Rect crop = parseCrop(args[6]);
|
Rect crop = parseCrop(args[7]);
|
||||||
options.setCrop(crop);
|
options.setCrop(crop);
|
||||||
|
|
||||||
boolean sendFrameMeta = Boolean.parseBoolean(args[7]);
|
boolean sendFrameMeta = Boolean.parseBoolean(args[8]);
|
||||||
options.setSendFrameMeta(sendFrameMeta);
|
options.setSendFrameMeta(sendFrameMeta);
|
||||||
|
|
||||||
boolean control = Boolean.parseBoolean(args[8]);
|
boolean control = Boolean.parseBoolean(args[9]);
|
||||||
options.setControl(control);
|
options.setControl(control);
|
||||||
|
|
||||||
int displayId = Integer.parseInt(args[9]);
|
int displayId = Integer.parseInt(args[10]);
|
||||||
options.setDisplayId(displayId);
|
options.setDisplayId(displayId);
|
||||||
|
|
||||||
boolean showTouches = Boolean.parseBoolean(args[10]);
|
boolean showTouches = Boolean.parseBoolean(args[11]);
|
||||||
options.setShowTouches(showTouches);
|
options.setShowTouches(showTouches);
|
||||||
|
|
||||||
boolean stayAwake = Boolean.parseBoolean(args[11]);
|
boolean stayAwake = Boolean.parseBoolean(args[12]);
|
||||||
options.setStayAwake(stayAwake);
|
options.setStayAwake(stayAwake);
|
||||||
|
|
||||||
String codecOptions = args[12];
|
String codecOptions = args[13];
|
||||||
options.setCodecOptions(codecOptions);
|
options.setCodecOptions(codecOptions);
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
|
@ -215,6 +218,9 @@ public final class Server {
|
||||||
});
|
});
|
||||||
|
|
||||||
Options options = createOptions(args);
|
Options options = createOptions(args);
|
||||||
|
|
||||||
|
Ln.initLogLevel(options.getLogLevel());
|
||||||
|
|
||||||
scrcpy(options);
|
scrcpy(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue