instead of coloring them, I’d recommend adding a tag/prefix that you can grep to filter out the logs you’re interested in.
After that you could pipe the logs through lolcat if you want colors
Also, I’m not sure what happens to the logs when they get forwarded to the controller, maybe the escape sequences are stripped at some point?
Yeah, I think trying to colour them before logging (and sending to the Juju controller) doesn’t sound right. They should be coloured as a UI thing at the time of display. That said, I’m not sure what’s breaking for you now – it could be there’s a maximum line length, or that the control characters are being stripped as Pietro suggested. Using a custom prefix as he showed seems like a reasonable way to do it. Could you also go on the module, for example __main__ in the example above?