[Pdbg] [PATCH 08/18] main: Add -D option to specify debug level

Amitay Isaacs amitay at ozlabs.org
Wed May 16 16:17:26 AEST 2018


Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
 src/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index 293f4e0..2070ef5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -129,6 +129,8 @@ static void print_usage(char *pname)
 	printf("\t-s, --slave-address=backend device address\n");
 	printf("\t\tDevice slave address to use for the backend. Not used by FSI\n");
 	printf("\t\tand defaults to 0x50 for I2C\n");
+	printf("\t-D, --debug=<debug level>\n");
+	printf("\t\t0:error (default) 1:warning 2:notice 3:info 4:debug\n");
 	printf("\t-V, --version\n");
 	printf("\t-h, --help\n");
 	printf("\n");
@@ -151,13 +153,14 @@ static bool parse_options(int argc, char *argv[])
 		{"processor",		required_argument,	NULL,	'p'},
 		{"slave-address",	required_argument,	NULL,	's'},
 		{"thread",		required_argument,	NULL,	't'},
+		{"debug",		required_argument,	NULL,	'V'},
 		{"version",		no_argument,		NULL,	'V'},
 		{NULL,			0,			NULL,     0}
 	};
 	char *endptr;
 
 	do {
-		c = getopt_long(argc, argv, "+ab:c:d:hp:s:t:V", long_opts, NULL);
+		c = getopt_long(argc, argv, "+ab:c:d:hp:s:t:D:V", long_opts, NULL);
 		if (c == -1)
 			break;
 
@@ -240,6 +243,10 @@ static bool parse_options(int argc, char *argv[])
 			opt_error = (errno || *endptr != '\0');
 			break;
 
+		case 'D':
+			pdbg_set_loglevel(atoi(optarg));
+			break;
+
 		case 'V':
 			errno = 0;
 			printf("%s (commit %s)\n", PACKAGE_STRING, GIT_SHA1);
-- 
2.17.0



More information about the Pdbg mailing list