in the first step carldani wants to introduce a verbosity level between
debug and spew.
the attached patch adds such a thing.

i argued that using a consistent naming scheme that indicates verbosity
with a number after the printing type instead of "info", "err", "dbg",
"spew" etc. would be better. for example msg_p2 (programmer messages at
verbosity level 2) or msg_g3 (general messages at verbosity level 3).
this was vetoed (for now at least ;).

instead of the multiple -V parameters we could add a number after the
first V (e.g. -V2 for verbosity level 2). this way we could also
include a silent mode more easily without a new character for the
parameter. there are no concrete plans for this though (afaik :).
my plan was to use the same numbers here and in the code to indicate
the level and to make -V0 the silent mode where only errors are
reported (or even nothing, and -V1 the error only mode..).

later the library code should support different verbosity levels for
different types (e.g. verbosity 1 for generic messages, but verbosity 3
for programmer messages). this does not need to be instantly available
for cli users though.

i probably forgot some things that have been discussed (and that's a
reason why i wrote the above so that at least that's not lost somewhere
in my head :).

we would like to hear any input of other devs regarding this of course!
-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner
>From 42ed4df6fb5ba126aae324b9a8d789807120e848 Mon Sep 17 00:00:00 2001
From: Stefan Tauner <[email protected]>
Date: Mon, 1 Aug 2011 19:06:14 +0200
Subject: [PATCH] introduce msg_*dbg2


Signed-off-by: Stefan Tauner <[email protected]>
---
 cli_output.c |    3 +++
 flash.h      |    6 +++++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/cli_output.c b/cli_output.c
index 1c85f7a..2a67bea 100644
--- a/cli_output.c
+++ b/cli_output.c
@@ -33,6 +33,9 @@ int print(int type, const char *fmt, ...)
 		output_type = stderr;
 		break;
 	case MSG_BARF:
+		if (verbose < 3)
+			return 0;
+	case MSG_DEBUG2:
 		if (verbose < 2)
 			return 0;
 	case MSG_DEBUG:
diff --git a/flash.h b/flash.h
index 5b49e9d..4b1cca2 100644
--- a/flash.h
+++ b/flash.h
@@ -233,7 +233,8 @@ int print(int type, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
 #define MSG_ERROR	0
 #define MSG_INFO	1
 #define MSG_DEBUG	2
-#define MSG_BARF	3
+#define MSG_DEBUG2	3
+#define MSG_BARF	4
 #define msg_gerr(...)	print(MSG_ERROR, __VA_ARGS__)	/* general errors */
 #define msg_perr(...)	print(MSG_ERROR, __VA_ARGS__)	/* programmer errors */
 #define msg_cerr(...)	print(MSG_ERROR, __VA_ARGS__)	/* chip errors */
@@ -243,6 +244,9 @@ int print(int type, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
 #define msg_gdbg(...)	print(MSG_DEBUG, __VA_ARGS__)	/* general debug */
 #define msg_pdbg(...)	print(MSG_DEBUG, __VA_ARGS__)	/* programmer debug */
 #define msg_cdbg(...)	print(MSG_DEBUG, __VA_ARGS__)	/* chip debug */
+#define msg_gdbg2(...)	print(MSG_DEBUG2, __VA_ARGS__)	/* general debug2 */
+#define msg_pdbg2(...)	print(MSG_DEBUG2, __VA_ARGS__)	/* programmer debug2 */
+#define msg_cdbg2(...)	print(MSG_DEBUG2, __VA_ARGS__)	/* chip debug2 */
 #define msg_gspew(...)	print(MSG_BARF, __VA_ARGS__)	/* general debug barf  */
 #define msg_pspew(...)	print(MSG_BARF, __VA_ARGS__)	/* programmer debug barf  */
 #define msg_cspew(...)	print(MSG_BARF, __VA_ARGS__)	/* chip debug barf  */
-- 
1.7.1

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to