Bukdu.jl icon indicating copy to clipboard operation
Bukdu.jl copied to clipboard

--color=no is ignored

Open anj00 opened this issue 6 years ago • 7 comments
trafficstars

From that I understand looking at the code Bukdu forces color output for logging even if julia is started with julia --color=no. This creates pretty messy logging in terminals which don't support color (in my case aws console)

I have the following workaround for now in my code:

#fix bug in Bukdu, which forces color output, ignoring command line arguments
force_bw = Base.JLOptions().color == 2
import Base.IOContext
using Base: ImmutableDict, unwrapcontext
function Base.IOContext(io::IO, dict::ImmutableDict)
    force_bw ? dict = ImmutableDict(dict, :color => false) : nothing
    io0 = unwrapcontext(io)[1]
    IOContext{typeof(io0)}(io0, dict)
end

ideally of course Bukdu should respect --color=no switch in julia

anj00 avatar May 20 '19 15:05 anj00

thanks for the issue

wookay avatar May 20 '19 15:05 wookay

could you test it again with master branch?

wookay avatar May 20 '19 15:05 wookay

Sorry, took a while. I think the fix is doing not exactly right thing (IMHO, but not a big deal for me) the fix shuts down color unless the user calls --color=yes, i.e. by default it is no color. Plus, somehow it shuts down color for other loggers.

I would expected: if user doesn't call --color, it is automatic. which is not the case with the current fix

I tried in Windows10 and ubuntu (in virtualbox with Windows and the host)

anj00 avatar May 27 '19 18:05 anj00

thanks. could you test it again?

wookay avatar May 27 '19 19:05 wookay

yes now it works as expected. Thanks!

anj00 avatar May 28 '19 06:05 anj00

Although, I didn't test in a terminal which doesn't support color.

I see that the current fix, just like my hack above checks if --color=no is pushed or not. I think (can't find it now) in julia they check both what user pushed and what terminal supports. and set color only if user pushed --color=yes or nothing is pushed (--color=auto) and terminal actually supports color.

i.e. I think the current fix will force color on terminals which don't support it, even if user set --color=auto (or didn't push anything)

anj00 avatar May 28 '19 06:05 anj00

I don't worry about the terminals for supporting colors or not. untested terminals like https://github.com/microsoft/terminal :)

wookay avatar May 28 '19 06:05 wookay