From 4d87d4e09b38d152425f060f088f3a44b7dacfcb Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Mon, 28 Jan 2013 14:39:43 +0800 Subject: cbfstool: Add -v (verbose) output. Add -v (verbose) to every command, and allow printing debug messages. Revise logging and debugging functions (fprintf(stderr,...), dprintf...) and verbose message printing with following macros: ERROR(xxx): E: xxx WARN(xxx) W: xxx LOG(xxx) xxx INFO(...) INFO: xxx (only when runs with -v ) DEBUG(...) DEBUG: xxx (only when runs with more than one -v) Example: cbfstool coreboot.rom print -v cbfstool coreboot.rom add -f file -n file -t raw -v -v Normal output (especially for parsing) should use printf, not any of these macros (see usage() and cbfs_locate(), cbfs_print_directory() for example). Change-Id: I167617da1a6eea2b07075b0eb38e3c9d85ea75dc Signed-off-by: Hung-Te Lin Reviewed-on: http://review.coreboot.org/2196 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks --- util/cbfstool/common.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'util/cbfstool/common.h') diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h index 853e5298a4..bb18ee1b9d 100644 --- a/util/cbfstool/common.h +++ b/util/cbfstool/common.h @@ -29,6 +29,14 @@ #define ntohll(x) (host_bigendian?(x):swab64(x)) #define htonll(x) (host_bigendian?(x):swab64(x)) +/* Message output */ +extern int verbose; +#define ERROR(x...) { fprintf(stderr, "E: " x); } +#define WARN(x...) { fprintf(stderr, "W: " x); } +#define LOG(x...) { fprintf(stderr, x); } +#define INFO(x...) { if (verbose > 0) fprintf(stderr, "INFO: " x); } +#define DEBUG(x...) { if (verbose > 1) fprintf(stderr, "DEBUG: " x); } + extern void *offset; extern uint32_t romsize; extern int host_bigendian; -- cgit v1.2.3