Log crashes in ConEmu in Windows but not in mintty
aboukirev opened this issue · 5 comments
Logging crashes with "runtime error: index out of range" in the log() function on line 173
f := fmt.Sprintf("%s|%s|%v\n", levels[v], l.prefix, msg)
in Windows in ConEmu console window. Works fine but no colors in mintty. My guess is ConEmu console is not recognized as *os.File
and variable levels
is not initialized. In my case log()
is called from Info()
so the level is INFO or 2, which I can see in the stack trace of panic output.
Perhaps, levels should always be initialized to some sensible values in SetOutput()
.
@aboukirev I have fixed the crashing issue. I would need you help to find what's the type of your io.Writer
. os.Stdout
is *os.File
.
@vishr Apparently go-colorable, when built in Windows, returns colorable.Writer
(extends io.Writer
. For other systems it returns os.Stdout
(which also implements io.Writer
). mintty
is part of msys2 toolchain that I am running and behaves as *nix/Posix, hence no issue there.
Verified your latest fix is working perfectly well. Thank you.
@aboukirev Did another commit, can you check if windows is getting colors?
@vishr Yes, the coloring works in both ConEmu and mintty. This is most excellent.
Cool.