[PATCH spice-streaming-agent v3 4/4] Add option to set logging categories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allows to enable/disable different categories of logging.
Currently disabling by default logging of full frame data which can take
huge amount of log and allow to enable it if needed.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 src/spice-streaming-agent.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 71ee184..1121f35 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -58,6 +58,7 @@ struct SpiceStreamDataMessage
 static bool streaming_requested = false;
 static bool quit_requested = false;
 static bool log_binary = false;
+static bool log_frames = false;
 static std::set<SpiceVideoCodecType> client_codecs;
 
 static bool have_something_to_read(StreamPort &stream_port, bool blocking)
@@ -254,6 +255,7 @@ static void usage(const char *progname)
     printf("\t-p portname  -- virtio-serial port to use\n");
     printf("\t-l file -- log frames to file\n");
     printf("\t--log-binary -- log binary frames (following -l)\n");
+    printf("\t--log-categories -- log categories, separated by ':' (currently: frames)\n");
     printf("\t--plugins-dir=path -- change plugins directory\n");
     printf("\t-d -- enable debug logs\n");
     printf("\t-c variable=value -- change settings\n");
@@ -391,7 +393,7 @@ do_capture(StreamPort &stream_port, FILE *f_log)
             if (f_log) {
                 if (log_binary) {
                     fwrite(frame.buffer, frame.buffer_size, 1, f_log);
-                } else {
+                } else if (log_frames) {
                     hexdump(frame.buffer, frame.buffer_size, f_log);
                 }
             }
@@ -422,10 +424,12 @@ int main(int argc, char* argv[])
         OPT_first = UCHAR_MAX,
         OPT_PLUGINS_DIR,
         OPT_LOG_BINARY,
+        OPT_LOG_CATEGORIES,
     };
     static const struct option long_options[] = {
         { "plugins-dir", required_argument, NULL, OPT_PLUGINS_DIR},
         { "log-binary", no_argument, NULL, OPT_LOG_BINARY},
+        { "log-categories", required_argument, NULL, OPT_LOG_CATEGORIES},
         { "help", no_argument, NULL, 'h'},
         { 0, 0, 0, 0}
     };
@@ -460,6 +464,15 @@ int main(int argc, char* argv[])
         case OPT_LOG_BINARY:
             log_binary = true;
             break;
+        case OPT_LOG_CATEGORIES:
+            for (const char *tok = strtok(optarg, ":"); tok; tok = strtok(nullptr, ":")) {
+                std::string cat = tok;
+                if (cat == "frames") {
+                    log_frames = true;
+                }
+                // ignore not existing, compatibility for future
+            }
+            break;
         case 'l':
             log_filename = optarg;
             break;
-- 
2.17.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]