1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

utils: renamed macros for color output

This commit is contained in:
Steffen Vogel 2017-07-12 00:50:29 +02:00
parent e17226995d
commit 94ae566091
11 changed files with 32 additions and 31 deletions

View file

@ -40,11 +40,11 @@ extern "C" {
#endif
/* The log level which is passed as first argument to print() */
#define LOG_LVL_DEBUG GRY("Debug")
#define LOG_LVL_INFO WHT("Info ")
#define LOG_LVL_WARN YEL("Warn ")
#define LOG_LVL_ERROR RED("Error")
#define LOG_LVL_STATS MAG("Stats")
#define LOG_LVL_DEBUG CLR_GRY("Debug")
#define LOG_LVL_INFO CLR_WHT("Info ")
#define LOG_LVL_WARN CLR_YEL("Warn ")
#define LOG_LVL_ERROR CLR_RED("Error")
#define LOG_LVL_STATS CLR_MAG("Stats")
/** Debug facilities.
*

View file

@ -41,21 +41,22 @@
#endif
/* Some color escape codes for pretty log messages */
#define GRY(str) "\e[30m" str "\e[0m" /**< Print str in gray */
#define RED(str) "\e[31m" str "\e[0m" /**< Print str in red */
#define GRN(str) "\e[32m" str "\e[0m" /**< Print str in green */
#define YEL(str) "\e[33m" str "\e[0m" /**< Print str in yellow */
#define BLU(str) "\e[34m" str "\e[0m" /**< Print str in blue */
#define MAG(str) "\e[35m" str "\e[0m" /**< Print str in magenta */
#define CYN(str) "\e[36m" str "\e[0m" /**< Print str in cyan */
#define WHT(str) "\e[37m" str "\e[0m" /**< Print str in white */
#define BLD(str) "\e[1m" str "\e[0m" /**< Print str in bold */
/* Alternate character set */
#define ACS(chr) "\e(0" chr "\e(B"
#define ACS_HORIZONTAL ACS("\x71")
#define ACS_VERTICAL ACS("\x78")
#define ACS_VERTRIGHT ACS("\x74")
#define CLR(clr, str) "\e[" XSTR(clr) "m" str "\e[0m"
#define CLR_GRY(str) CLR(30, str) /**< Print str in gray */
#define CLR_RED(str) CLR(31, str) /**< Print str in red */
#define CLR_GRN(str) CLR(32, str) /**< Print str in green */
#define CLR_YEL(str) CLR(33, str) /**< Print str in yellow */
#define CLR_BLU(str) CLR(34, str) /**< Print str in blue */
#define CLR_MAG(str) CLR(35, str) /**< Print str in magenta */
#define CLR_CYN(str) CLR(36, str) /**< Print str in cyan */
#define CLR_WHT(str) CLR(37, str) /**< Print str in white */
#define CLR_BLD(str) CLR( 1, str) /**< Print str in bold */
/* CPP stringification */
#define XSTR(x) STR(x)

View file

@ -24,11 +24,11 @@ void rtds_axis_dump(struct fpga_ip *c)
{ INDENT
info("RTDS status: %#08x", sr);
{ INDENT
info("Card detected: %s", sr & RTDS_AXIS_SR_CARDDETECTED ? GRN("yes") : RED("no"));
info("Link up: %s", sr & RTDS_AXIS_SR_LINKUP ? GRN("yes") : RED("no"));
info("TX queue full: %s", sr & RTDS_AXIS_SR_TX_FULL ? RED("yes") : GRN("no"));
info("TX in progress: %s", sr & RTDS_AXIS_SR_TX_INPROGRESS ? YEL("yes") : "no");
info("Case running: %s", sr & RTDS_AXIS_SR_CASE_RUNNING ? GRN("yes") : RED("no"));
info("Card detected: %s", sr & RTDS_AXIS_SR_CARDDETECTED ? CLR_GRN("yes") : CLR_RED("no"));
info("Link up: %s", sr & RTDS_AXIS_SR_LINKUP ? CLR_GRN("yes") : CLR_RED("no"));
info("TX queue full: %s", sr & RTDS_AXIS_SR_TX_FULL ? CLR_RED("yes") : CLR_GRN("no"));
info("TX in progress: %s", sr & RTDS_AXIS_SR_TX_INPROGRESS ? CLR_YEL("yes") : "no");
info("Case running: %s", sr & RTDS_AXIS_SR_CASE_RUNNING ? CLR_GRN("yes") : CLR_RED("no"));
}
info("RTDS control: %#08x", regs[RTDS_AXIS_CR_OFFSET/4]);

View file

@ -207,7 +207,7 @@ int node_write(struct node *n, struct sample *smps[], unsigned cnt)
char * node_name(struct node *n)
{
if (!n->_name)
strcatf(&n->_name, RED("%s") "(" YEL("%s") ")", n->name, plugin_name(n->_vt));
strcatf(&n->_name, CLR_RED("%s") "(" CLR_YEL("%s") ")", n->name, plugin_name(n->_vt));
return n->_name;
}

View file

@ -36,7 +36,7 @@ int node_type_start(struct node_type *vt, struct super_node *sn)
if (vt->state != STATE_DESTROYED)
return 0;
info("Initializing " YEL("%s") " node type which is used by %zu nodes", node_type_name(vt), list_length(&vt->instances));
info("Initializing " CLR_YEL("%s") " node type which is used by %zu nodes", node_type_name(vt), list_length(&vt->instances));
{ INDENT
ret = vt->init ? vt->init(sn) : 0;
}
@ -54,7 +54,7 @@ int node_type_stop(struct node_type *vt)
if (vt->state != STATE_STARTED)
return 0;
info("De-initializing " YEL("%s") " node type", node_type_name(vt));
info("De-initializing " CLR_YEL("%s") " node type", node_type_name(vt));
{ INDENT
ret = vt->deinit ? vt->deinit() : 0;
}

View file

@ -404,12 +404,12 @@ const char * path_name(struct path *p)
if (list_length(&p->destinations) == 1) {
struct path_destination *pd = (struct path_destination *) list_first(&p->destinations);
strcatf(&p->_name, "%s " MAG("=>") " %s",
strcatf(&p->_name, "%s " CLR_MAG("=>") " %s",
node_name_short(p->source->node),
node_name_short(pd->node));
}
else {
strcatf(&p->_name, "%s " MAG("=>") " [", node_name_short(p->source->node));
strcatf(&p->_name, "%s " CLR_MAG("=>") " [", node_name_short(p->source->node));
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = list_at(&p->destinations, i);

View file

@ -39,7 +39,7 @@ pthread_t main_thread;
void print_copyright()
{
printf("VILLASnode %s (built on %s %s)\n",
BLU(BUILDID), MAG(__DATE__), MAG(__TIME__));
CLR_BLU(BUILDID), CLR_MAG(__DATE__), CLR_MAG(__TIME__));
printf(" Copyright 2014-2017, Institute for Automation of Complex Power Systems, EONERC\n");
printf(" Steffen Vogel <StVogel@eonerc.rwth-aachen.de>\n");
}

View file

@ -50,7 +50,7 @@ static void quit(int signal, siginfo_t *sinfo, void *ctx)
super_node_stop(&sn);
super_node_destroy(&sn);
info(GRN("Goodbye!"));
info(CLR_GRN("Goodbye!"));
exit(EXIT_SUCCESS);
}
@ -101,8 +101,8 @@ int main(int argc, char *argv[])
usage();
#endif
info("This is VILLASnode %s (built on %s, %s)", BLD(YEL(BUILDID)),
BLD(MAG(__DATE__)), BLD(MAG(__TIME__)));
info("This is VILLASnode %s (built on %s, %s)", CLR_BLD(CLR_YEL(BUILDID)),
CLR_BLD(CLR_MAG(__DATE__)), CLR_BLD(CLR_MAG(__TIME__)));
/* Checks system requirements*/
struct version kver, reqv = { KERNEL_VERSION_MAJ, KERNEL_VERSION_MIN };

View file

@ -74,7 +74,7 @@ static void quit(int signal, siginfo_t *sinfo, void *ctx)
super_node_stop(&sn);
super_node_destroy(&sn);
info(GRN("Goodbye!"));
info(CLR_GRN("Goodbye!"));
exit(EXIT_SUCCESS);
}

View file

@ -81,7 +81,7 @@ static void quit(int signal, siginfo_t *sinfo, void *ctx)
{
signal_close(&n);
info(GRN("Goodbye!"));
info(CLR_GRN("Goodbye!"));
exit(EXIT_SUCCESS);
}

View file

@ -305,7 +305,7 @@ Test(fpga, dma, .description = "DMA")
ret = memcmp(src.base_virt, dst.base_virt, src.len);
info("DMA %s (%s): %s", dm->name, dma->inst.HasSg ? "scatter-gather" : "simple", ret ? RED("failed") : GRN("passed"));
info("DMA %s (%s): %s", dm->name, dma->inst.HasSg ? "scatter-gather" : "simple", ret ? CLR_RED("failed") : CLR_GRN("passed"));
ret = switch_disconnect(card->sw, dm, dm);
cr_assert_eq(ret, 0, "Failed to configure switch");