]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
FCB learned option to change verbosity
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 25 May 2009 18:23:36 +0000 (20:23 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 25 May 2009 18:23:36 +0000 (20:23 +0200)
fres/cbroker/fcb.c

index 1ed13b1622922540b99521cfb2333916c8e4afff..77103a4f27d7c95b36d7693939cb404dcd5b6fb2 100644 (file)
@@ -53,6 +53,7 @@
  * 
  * 
  */
+#include <getopt.h>
 #include <forb.h>
 #include <forb/config.h>
 #include <fcb.h>
@@ -62,6 +63,7 @@
 #include <ul_gavlcust.h>
 #include <string.h>
 #include <ul_log.h>
+#include <ul_logreg.h>
 #include <forb/server_id.h>
 #include <fres_contract.h>
 #include "fcb_config.h"
@@ -939,6 +941,18 @@ void peer_dead_callback(const forb_orb peer_orb, const char *orb_id)
 {
 }
 
+static struct option long_opts[] = {
+    { "loglevel", 1, 0, 'l' },
+    { 0, 0, 0, 0}
+};
+
+static void
+usage(void)
+{
+       printf("usage: fcb [ options ]\n");
+       printf("  -l, --loglevel <number>|<domain>=<number>,...\n");
+}
+
 int main(int argc, char *argv[])
 {
        forb_orb orb;
@@ -951,7 +965,21 @@ int main(int argc, char *argv[])
                .peer_discovery_callback = peer_discovery_callback,
                .peer_dead_callback = peer_dead_callback,
        };
-
+       int  opt;
+
+       ul_logreg_domain(&ulogd_fcb);
+
+       while ((opt = getopt_long(argc, argv, "l:", &long_opts[0], NULL)) != EOF) {
+               switch (opt) {
+                       case 'l':
+                               ul_log_domain_arg2levels(optarg);
+                               break;
+                       case 'h':
+                       default:
+                               usage();
+                               exit(opt == 'h' ? 0 : 1);
+               }
+       }
 
        fosa_clock_get_time(CLOCK_REALTIME, &start_time);