disable colors when not output is not a tty
mtourne opened this issue · 6 comments
mtourne commented
Colors are great and make the output very readable, however it's a pain when trying to output to a file
go-isatty[1] seems like it would be a good addition to this project to solve this
zelenko commented
Would be nice to have option to disable colors.
bigkraig commented
Obviously nicer to have a function that does this, but can't you just do something like this?
pp.SetColorScheme(pp.ColorScheme{
Bool: pp.NoColor,
Integer: pp.NoColor,
Float: pp.NoColor,
String: pp.NoColor,
StringQuotation: pp.NoColor,
EscapedChar: pp.NoColor,
FieldName: pp.NoColor,
PointerAdress: pp.NoColor,
Nil: pp.NoColor,
Time: pp.NoColor,
StructName: pp.NoColor,
ObjectLength: pp.NoColor,
})
pocari commented
You can use pp.ColoringEnabled = false
.
k0kubun commented
Right, thanks for your comment!
makenowjust commented
@k0kubun Why is ColoringEnabled
placed as package variable instead of PrettyPrinter
member? I need to disable coloring of individual PrettyPrinter
. (Is this question out of scoping of this issue, I wonder. Sorry.)
k0kubun commented