Colouring the output of println

My new package’s tests include println lines to explain the tests being run so that their output is more helpful. It would be nice to be able to distinguish println line outputs from the other outputs using colour coding. Is there a way to colour the output of println? The only relevant result from running a DuckDuckGo search for: “println colour output julia” was Printf · The Julia Language and it doesn’t mention any colouring options. Nor does ?println. So I suspect there’s no in-built option to colour the output, I’m just hoping someone has a workaround.

In Base there is the function printstyled([io], xs...; bold::Bool=false, color::Union{Symbol,Int}=:normal), note that you will need to add “\n” to match println behaviour. E.g.

printstyled("Hello\n"; color = :blue)
8 Likes

There is also

https://github.com/KristofferC/Crayons.jl

1 Like