From dad451f6f9542c03d8fbf219ff0ffd62adcf9487 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 15 Sep 2012 10:46:07 +0200 Subject: [PATCH] Add a command line option to increase the loglevel. By default, the universal application will always log error and warning messages, but the loglevel can be increased to also log info and debug messages. --- examples/universal.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/universal.c b/examples/universal.c index bbc717d..4eadd7a 100644 --- a/examples/universal.c +++ b/examples/universal.c @@ -704,6 +704,7 @@ main (int argc, char *argv[]) { // Default values. dc_family_t backend = DC_FAMILY_NULL; + dc_loglevel_t loglevel = DC_LOGLEVEL_WARNING; const char *name = NULL; const char *logfile = "output.log"; const char *rawfile = "output.bin"; @@ -716,7 +717,7 @@ main (int argc, char *argv[]) #ifndef _MSC_VER // Parse command-line options. int opt = 0; - while ((opt = getopt (argc, argv, "n:b:t:f:l:m:d:c:h")) != -1) { + while ((opt = getopt (argc, argv, "n:b:t:f:l:m:d:c:vh")) != -1) { switch (opt) { case 'n': name = optarg; @@ -734,6 +735,9 @@ main (int argc, char *argv[]) case 'l': logfile = optarg; break; + case 'v': + loglevel++; + break; case 'm': memory = 1; rawfile = optarg; @@ -780,7 +784,7 @@ main (int argc, char *argv[]) return EXIT_FAILURE; } - dc_context_set_loglevel (context, DC_LOGLEVEL_ALL); + dc_context_set_loglevel (context, loglevel); dc_context_set_logfunc (context, logfunc, NULL); /* Search for a matching device descriptor. */