0%

use colorwheel to print colored message in console with cpp programs

Guide

install

1
sudo wget -O /usr/include/colorwheel.h https://raw.githubusercontent.com/Totoditoto/colorwheel/master/colorwheel.h

install to /usr/include/colorwheel.h

usage

only include header

1
#include <colorwheel.h>

macros

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* Predefined printf styled messages */
CW_PRINT_NORMAL(message, ...);
CW_PRINT_ALARM(message, ...);
CW_PRINT_CRITICAL(message, ...);
CW_PRINT_FAULT(message, ...);
CW_PRINT_VALID(message, ...);
CW_PRINT_INFO(message, ...);

/* Predefined trace styled messages (indicates file, function and line) */
CW_TRACE_NORMAL(message, ...);
CW_TRACE_ALARM(message, ...);
CW_TRACE_CRITICAL(message, ...);
CW_TRACE_FAULT(message, ...);
CW_TRACE_VALID(message, ...);
CW_TRACE_INFO(message, ...);

code

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <colorwheel.h>

void demo_colorwheel(void)
{
CW_TRACE_NORMAL("This is a normal information");
CW_TRACE_INFO("This is a noticeable information");
CW_TRACE_FAULT("Ooops something might have gone wrong");
CW_TRACE_VALID("Finally it's okay, don't worry");
//CW_TRACE_NORMAL("Nevermind");
int value = 10;
CW_TRACE_CRITICAL("It was way worse than expected! Computer will explode in %d s", value);
CW_TRACE_ALARM("IT IS TOO LATE RUN AWAY");
}

colored print

Reference

History

  • 20191010: created.