The build process output a lot of text. It is sometimes difficult to spot errors and warnings.
It could be great if the output could be colorized (red for errors, orange/yellow for warning etc), to make the build log more readable.
I've added add_compile_options (-fdiagnostics-color=always) to the main CMakeList.txt file of my project and set an environment variable GCC_COLORS="error=01;31:warning=01;33:note=01;36:caret=01;32:locus=01:quote=01" which give me some colored output. Is there any better way to do this?
There is no official support for this in the sense that you can't pass an argument to idf.py to enable this. You can, however, skip adding add_compile_options (-fdiagnostics-color=always) to every project you work with OR by adding the -fdiagnostics-color=always to the environment variable EXTRA_CFLAGS and EXTRA_CXXFLAGS to have it be "permanent".
You still need to set the GCC_COLORS however for the colors you want the output to be.
You can colorize the log with following code.
static const char *TAG = "TEST_TASK";
ESP_LOG_LEVEL(ESP_LOG_ERROR, TAG, "%d - Red log", 1);
ESP_LOG_LEVEL(ESP_LOG_WARN, TAG, "%d - Yello log", 2);
ESP_LOG_LEVEL(ESP_LOG_INFO, TAG, "%d - Green log", 3);
I found the way from the source code of esp_log.h
@esanai I think @AloyseTech was referring to colorizing the actual output build log, not the runtime logs.
@renzbagaporo You are right. I'm sorry for my misunderstanding.
There is no official support for this in the sense that you can't pass an argument to
idf.pyto enable this. You can, however, skip addingadd_compile_options (-fdiagnostics-color=always)to every project you work with OR by adding the -fdiagnostics-color=alwaysto the environment variable EXTRA_CFLAGS and EXTRA_CXXFLAGS to have it be "permanent".You still need to set the GCC_COLORS however for the colors you want the output to be.
Or the devs could actually fix this? It works with Make, for heaven's sake.
This issue needs to be reopened.
Add the parameters onto the environment, by executing:
export EXTRA_CFLAGS=-fdiagnostics-color=always
export GCC_COLORS="error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:quote=01:path=01;36:fixit-insert=32:fixit-delete=31:diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:type-diff=01;32"
before my idf.py build command, but still only B&W output. Obviously doing something wrong.
Ps. Putting the some definitive handles here how to enable colour build-output would would surely help a lot of people, as this issue is where people land when searching for coloured build output.
Most helpful comment
Add the parameters onto the environment, by executing:
before my
idf.py buildcommand, but still only B&W output. Obviously doing something wrong.Ps. Putting the some definitive handles here how to enable colour build-output would would surely help a lot of people, as this issue is where people land when searching for coloured build output.