[Spice-devel] [PATCH spice-streaming-agent v2 4/4] Add option to set logging categories

Frediano Ziglio fziglio at redhat.com
Mon May 21 10:23:08 UTC 2018


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 at redhat.com>
---
 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 d694eab..2325119 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");
@@ -388,7 +390,7 @@ do_capture(StreamPort &stream_port, FILE *f_log)
                 spice_stream_send_format(stream_port, width, height, codec);
             }
             STAT_LOG("Frame of %zu bytes:", frame.buffer_size);
-            if (f_log) {
+            if (f_log && log_frames) {
                 if (log_binary) {
                     fwrite(frame.buffer, frame.buffer_size, 1, f_log);
                 } else {
@@ -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



More information about the Spice-devel mailing list