WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xl: Allow control of logging level.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: Allow control of logging level.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 29 May 2010 00:31:15 -0700
Delivery-date: Sat, 29 May 2010 00:36:40 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1275035712 -3600
# Node ID 7e17e7c0f39333b9abcbfc3dafcbfd9ffbbd5805
# Parent  7ca2d912530c27f3c8e4912de01a0c76efa721d7
xl: Allow control of logging level.

The -v option, which must come before the xl command, increases the
logging level each time it is supplied.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxc/xtl_logger_stdio.c |    5 ++++-
 tools/libxl/xl.c               |   40 ++++++++++++++++++++++++++++------------
 tools/libxl/xl.h               |    2 +-
 3 files changed, 33 insertions(+), 14 deletions(-)

diff -r 7ca2d912530c -r 7e17e7c0f393 tools/libxc/xtl_logger_stdio.c
--- a/tools/libxc/xtl_logger_stdio.c    Fri May 28 09:34:42 2010 +0100
+++ b/tools/libxc/xtl_logger_stdio.c    Fri May 28 09:35:12 2010 +0100
@@ -35,6 +35,9 @@ static void stdiostream_vmessage(xentool
                                  const char *format,
                                  va_list al) {
     xentoollog_logger_stdiostream *lg = (void*)logger_in;
+
+    if (level < lg->min_level)
+        return;
 
     progress_erase(lg);
 
@@ -82,7 +85,7 @@ static void stdiostream_progress(struct 
         this_level = XTL_PROGRESS;
     }
 
-    if (lg->min_level < this_level)
+    if (this_level < lg->min_level)
         return;
 
     if (lg->progress_erase_len)
diff -r 7ca2d912530c -r 7e17e7c0f393 tools/libxl/xl.c
--- a/tools/libxl/xl.c  Fri May 28 09:34:42 2010 +0100
+++ b/tools/libxl/xl.c  Fri May 28 09:35:12 2010 +0100
@@ -31,19 +31,38 @@
 #include "libxl_utils.h"
 #include "xl.h"
 
-xentoollog_logger *logger;
+xentoollog_logger_stdiostream *logger;
+
+static xentoollog_level minmsglevel = XTL_PROGRESS;
 
 int main(int argc, char **argv)
 {
-    int i;
+    int opt = 0, i;
+    char *cmd = 0;
 
-    if (argc < 2) {
+    while ((opt = getopt(argc, argv, "+v")) >= 0) {
+        switch (opt) {
+        case 'v':
+            if (minmsglevel > 0) minmsglevel--;
+            break;
+        default:
+            fprintf(stderr, "unknown global option\n");
+            exit(2);
+        }
+    }
+
+    cmd = argv[optind++];
+
+    if (!cmd) {
         help(NULL);
         exit(1);
     }
+    opterr = 0;
 
-    logger = xtl_createlogger_stdiostream(stderr, XTL_PROGRESS,  0);
-    if (libxl_ctx_init(&ctx, LIBXL_VERSION, logger)) {
+    logger = xtl_createlogger_stdiostream(stderr, minmsglevel,  0);
+    if (!logger) exit(1);
+
+    if (libxl_ctx_init(&ctx, LIBXL_VERSION, (xentoollog_logger*)logger)) {
         fprintf(stderr, "cannot init xl context\n");
         exit(1);
     }
@@ -51,16 +70,13 @@ int main(int argc, char **argv)
     srand(time(0));
 
     for (i = 0; i < cmdtable_len; i++) {
-        if (!strcmp(argv[1], cmd_table[i].cmd_name))
-               cmd_table[i].cmd_impl(argc - 1, argv + 1);
+        if (!strcmp(cmd, cmd_table[i].cmd_name))
+               cmd_table[i].cmd_impl(argc, argv);
     }
 
     if (i >= cmdtable_len) {
-        if (!strcmp(argv[1], "help")) {
-            if (argc > 2)
-                help(argv[2]);
-            else
-                help(NULL);
+        if (!strcmp(cmd, "help")) {
+            help(argv[1]);
             exit(0);
         } else {
             fprintf(stderr, "command not implemented\n");
diff -r 7ca2d912530c -r 7e17e7c0f393 tools/libxl/xl.h
--- a/tools/libxl/xl.h  Fri May 28 09:34:42 2010 +0100
+++ b/tools/libxl/xl.h  Fri May 28 09:35:12 2010 +0100
@@ -77,6 +77,6 @@ extern int cmdtable_len;
 extern int cmdtable_len;
 
 extern struct libxl_ctx ctx;
-extern xentoollog_logger *logger;
+extern xentoollog_logger_stdiostream *logger;
 
 #endif /* XL_H */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xl: Allow control of logging level., Xen patchbot-unstable <=