Copying the "custom color" example code from the README to example.go and running it:
$ go run example.go 2> file
$ cat -vet file
^[[31mERRO^[[0m[0000] foo bar baz!!! 5 $
^[[34mINFO^[[0m[0000] A group of walrus emerges from the ocean ^[[34manimal^[[0m=walrus ^[[34msize^[[0m=10$
^[[33mWARN^[[0m[0000] The group's number increased tremendously! ^[[33mnumber^[[0m=122 ^[[33momg^[[0m=true$
^[[31mFATA^[[0m[0000] The ice breaks! ^[[31mnumber^[[0m=100 ^[[31momg^[[0m=true$
exit status 1$
It looks like the color detection code is only looking at stdout. If I redirect only stdout to a file the color goes away, even though the output is still visible in the terminal!
@oconnor663 you're right. If you feel like providing a PR, that'd be great. Otherwise I'll fix it sometime in the future.
@oconnor663 I can't reproduce this issue. Do you have any special terminal ?
â–¶ go run examples/basic/basic.go 2> file
â–¶ cat -vet file
time="2016-05-24T20:30:16+02:00" level=debug msg="Started observing beach" animal=walrus number=8 $
time="2016-05-24T20:30:16+02:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10 $
time="2016-05-24T20:30:16+02:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true $
time="2016-05-24T20:30:16+02:00" level=debug msg="Temperature changes" temperature=-4 $
time="2016-05-24T20:30:16+02:00" level=panic msg="It's over 9000!" animal=orca size=9009 $
time="2016-05-24T20:30:16+02:00" level=fatal msg="The ice breaks!" err=&{0xc8200122c0 map[animal:orca size:9009] 2016-05-24 20:30:16.035454715 +0200 CEST panic It's over 9000!} number=100 omg=true $
exit status 1$
@camilocot hmm yeah, I can't seem to reproduce it anymore either. Fixed?
Most helpful comment
@oconnor663 you're right. If you feel like providing a PR, that'd be great. Otherwise I'll fix it sometime in the future.