diff options
author | Michael Brown <mcb30@ipxe.org> | 2014-06-16 16:28:20 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2014-06-16 16:53:26 +0100 |
commit | 13a74e0d27a6b4781cca4646642e635cbbc94796 (patch) | |
tree | 1c43f8027d936824069458fcc7bdd94863d9d839 /src/core/debug.c | |
parent | 1639978f5a3ed821eeb752f81af0093884384de4 (diff) | |
download | ipxe-13a74e0d27a6b4781cca4646642e635cbbc94796.tar.gz |
[debug] Allow debug message colours to be customised via DBGCOL=...
When multiple iPXE binaries are running concurrently (e.g. in the case
of undionly.kpxe using an underlying iPXE driver via the UNDI
interface) it would be helpful to be able to visually distinguish
debug messages from each binary.
Allow the range of debug colours used to be customised via the
DBGCOL=... build parameter. For example:
# Restrict to colours 31-33 (red, green, yellow)
make DBGCOL=31-33
# Restrict to colours 34-36 (blue, magenta, cyan)
make DBGCOL=34-36
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/debug.c')
-rw-r--r-- | src/core/debug.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/core/debug.c b/src/core/debug.c index 2161f9731..7ded47089 100644 --- a/src/core/debug.c +++ b/src/core/debug.c @@ -119,13 +119,24 @@ void dbg_hex_dump_da ( unsigned long dispaddr, const void *data, } /** + * Base message stream colour + * + * We default to using 31 (red foreground) as the base colour. + */ +#ifndef DBGCOL_MIN +#define DBGCOL_MIN 31 +#endif + +/** * Maximum number of separately coloured message streams * * Six is the realistic maximum; there are 8 basic ANSI colours, one * of which will be the terminal default and one of which will be * invisible on the terminal because it matches the background colour. */ -#define NUM_AUTO_COLOURS 6 +#ifndef DBGCOL_MAX +#define DBGCOL_MAX ( DBGCOL_MIN + 6 - 1 ) +#endif /** A colour assigned to an autocolourised debug message stream */ struct autocolour { @@ -142,7 +153,7 @@ struct autocolour { * @ret colour Colour ID */ static int dbg_autocolour ( unsigned long stream ) { - static struct autocolour acs[NUM_AUTO_COLOURS]; + static struct autocolour acs[ DBGCOL_MAX - DBGCOL_MIN + 1 ]; static unsigned long use; unsigned int i; unsigned int oldest; @@ -180,7 +191,7 @@ static int dbg_autocolour ( unsigned long stream ) { */ void dbg_autocolourise ( unsigned long stream ) { dbg_printf ( "\033[%dm", - ( stream ? ( 31 + dbg_autocolour ( stream ) ) : 0 ) ); + ( stream ? ( DBGCOL_MIN + dbg_autocolour ( stream ) ) :0)); } /** |