This is a lot of repeated code. How about using two variables, one for the prefix and one for the color, and combining them after the switch?

Also, we use braces for all control blocks, so all your ifs and elses should have braces, which would make this noodle of a code twice as long :(

I know you've just moved the code, but you can improve it in the meantime, too.

Moved this comment from the specific commit to the PR, so it may appear twice, sorry for that.