Print color to the terminal and log no-color to a file from the same terraform command

I would like a feature for the terraform cli commands to print color codes in terminal output but not when logging to a file.

I like to read the plans, outputs and errors in color in the terminal, but increasingly I also tee the output to a file for my LLM or Agent to read and consider.
The ANSI color codes are garbage tokens to an LLM.

One possible solution could be for the cli to automatically detect if it is a terminal or file output with is_a_tty or to provide a built in -log file, option that does the tee and removes color.
Something along these lines might be possible.

It would be possible to write a filter to strip the codes but that would be a less elegant solution.

1 Like