KAI supports colored console output for logs and test results, making it easier to distinguish between different types of messages (INFO, WARNING, ERROR) and improving overall readability.
-
Colored Log Messages: Different types of log messages are displayed in distinct colors:
- INFO messages in green
- WARNING messages in yellow
- ERROR and FATAL messages in red (with bold formatting)
-
Colored Test Output: Test output messages use the same color scheme:
- Grey for console metadata (e.g., line prefixes)
- Green for INFO messages
- Red (bold) for ERROR messages
-
Default Behavior: Color output is enabled by default in all test programs.
The following command-line options control colored output:
--debug-coloror--color: Explicitly enable colored output (redundant as color is on by default)--no-color: Disable colored output
Example usage:
# Run with colored output (default)
./Bin/Test/TestPi
# Explicitly enable colored output
./Bin/Test/TestPi --color
# Disable colored output
./Bin/Test/TestPi --no-colorThe color output system uses the rang library for terminal color and formatting. Key components:
- Global color state in
Main.cpp - Integration with the
Loggerclass for consistent coloring of all logs - Grey console input formatting
- Support for output redirection (colors are forced on with
--color, automatically disabled with output redirection unless--coloris specified)
Here's an example of colored output:
[2025-05-18 23:03:08] [INFO] TranslatorCommon::Append: Directly evaluated 2 Plus 3 = 5
[2025-05-18 23:03:08] [WARNING] Saved continuation is not valid, setting to empty continuation
[2025-05-18 23:03:08] [ERROR] Failed to execute operation
In a terminal, these would appear as:
- INFO message in green
- WARNING in yellow
- ERROR in red bold text
Main.cpp: Command-line argument handling and global color settingsTestCommon.h: TestCout implementation with color supportDebug.cpp: Integration with Logger for consistent coloringLogger.cpp: Color formatting for different log levels