From 2e392db2cbd125b319ad98136016bca0846f7e6a Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Thu, 17 Jun 2021 22:40:30 +0300 Subject: [PATCH] Add --verbosity=verbose log level --- app/src/cli.c | 7 ++++++- app/src/main.c | 2 ++ app/src/scrcpy.h | 1 + app/src/server.c | 2 ++ server/src/main/java/com/genymobile/scrcpy/Ln.java | 9 ++++++++- server/src/main/java/com/genymobile/scrcpy/Server.java | 1 + 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/cli.c b/app/src/cli.c index 3e5d613dff..1faa3b19df 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -184,7 +184,7 @@ scrcpy_print_usage(const char *arg0) { "\n" #endif " -V, --verbosity value\n" - " Set the log level (debug, info, warn or error).\n" + " Set the log level (verbose, debug, info, warn or error).\n" #ifndef NDEBUG " Default is debug.\n" #else @@ -505,6 +505,11 @@ parse_display_id(const char *s, uint32_t *display_id) { static bool parse_log_level(const char *s, enum sc_log_level *log_level) { + if (!strcmp(s, "verbose")) { + *log_level = SC_LOG_LEVEL_VERBOSE; + return true; + } + if (!strcmp(s, "debug")) { *log_level = SC_LOG_LEVEL_DEBUG; return true; diff --git a/app/src/main.c b/app/src/main.c index a468aed7f1..c3a7ad2eae 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -41,6 +41,8 @@ print_version(void) { static SDL_LogPriority convert_log_level_to_sdl(enum sc_log_level level) { switch (level) { + case SC_LOG_LEVEL_VERBOSE: + return SDL_LOG_PRIORITY_VERBOSE; case SC_LOG_LEVEL_DEBUG: return SDL_LOG_PRIORITY_DEBUG; case SC_LOG_LEVEL_INFO: diff --git a/app/src/scrcpy.h b/app/src/scrcpy.h index 405dc7f3b6..0a2deb71e2 100644 --- a/app/src/scrcpy.h +++ b/app/src/scrcpy.h @@ -8,6 +8,7 @@ #include enum sc_log_level { + SC_LOG_LEVEL_VERBOSE, SC_LOG_LEVEL_DEBUG, SC_LOG_LEVEL_INFO, SC_LOG_LEVEL_WARN, diff --git a/app/src/server.c b/app/src/server.c index 41e8166c0a..a4cdb0c970 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -235,6 +235,8 @@ enable_tunnel_any_port(struct server *server, struct sc_port_range port_range, static const char * log_level_to_server_string(enum sc_log_level level) { switch (level) { + case SC_LOG_LEVEL_VERBOSE: + return "verbose"; case SC_LOG_LEVEL_DEBUG: return "debug"; case SC_LOG_LEVEL_INFO: diff --git a/server/src/main/java/com/genymobile/scrcpy/Ln.java b/server/src/main/java/com/genymobile/scrcpy/Ln.java index c218fa0fc0..061cda9595 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Ln.java +++ b/server/src/main/java/com/genymobile/scrcpy/Ln.java @@ -12,7 +12,7 @@ public final class Ln { private static final String PREFIX = "[server] "; enum Level { - DEBUG, INFO, WARN, ERROR + VERBOSE, DEBUG, INFO, WARN, ERROR } private static Level threshold = Level.INFO; @@ -36,6 +36,13 @@ public static boolean isEnabled(Level level) { return level.ordinal() >= threshold.ordinal(); } + public static void v(String message) { + if (isEnabled(Level.VERBOSE)) { + Log.v(TAG, message); + System.out.println(PREFIX + "VERBOSE: " + message); + } + } + public static void d(String message) { if (isEnabled(Level.DEBUG)) { Log.d(TAG, message); diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java index 674f314b63..ba604577c7 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Server.java +++ b/server/src/main/java/com/genymobile/scrcpy/Server.java @@ -251,6 +251,7 @@ public void uncaughtException(Thread t, Throwable e) { Options options = createOptions(args); Ln.initLogLevel(options.getLogLevel()); + Ln.v("Using verbose log level"); scrcpy(options); }