From 5a1e08f099e53fe3ee16692f3aef804518d75081 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 PR #2371 Signed-off-by: Romain Vimont --- app/scrcpy.1 | 2 +- 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 ++++++++- 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/scrcpy.1 b/app/scrcpy.1 index 7b6f1faa69..62dc9677d8 100644 --- a/app/scrcpy.1 +++ b/app/scrcpy.1 @@ -193,7 +193,7 @@ It requires to lock the video orientation (see --lock-video-orientation). .TP .BI "\-V, \-\-verbosity " value -Set the log level ("debug", "info", "warn" or "error"). +Set the log level ("verbose", "debug", "info", "warn" or "error"). Default is "info" for release builds, "debug" for debug builds. diff --git a/app/src/cli.c b/app/src/cli.c index 6e1180bc2e..4c1fbb2f3e 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);