Skip to content

[Log] Add possibility to disable colorization of log outputs

Context

Add possibility to disable color ANSI escape sequences for the cases where the terminal does not support it or the output is redirected to a file/pipe.

Example 1:

# run unit test without colors in notices/warnings
env AIDGE_LOG_COLOR=off build/unit_tests/tests_aidge_core

Example 2:

# python script
import aidge_core
aidge_core.Log.set_console_color(False)
aidge_core.Log.warn("uncolored warning")

Modified files

  • Log.hpp: Add setConsoleColor(bool) method to Log module in order to control colorization on log outputs. Default should be assumed true.
  • pybind_Log.cpp: Add set_console_color(bool) python binding.
  • Log.cpp initial value: Add AIDGE_LOG_COLOR=[off|OFF|0] env var to disable colors at startup.

Detailed major modifications

No major modification.

Added a new interface to python and through env vars.

TODO

No TODO forecasted

Merge request reports

Loading