1// +build !windows
2
3package hclog
4
5import (
6	"github.com/mattn/go-isatty"
7)
8
9// setColorization will mutate the values of this logger
10// to approperately configure colorization options. It provides
11// a wrapper to the output stream on Windows systems.
12func (l *intLogger) setColorization(opts *LoggerOptions) {
13	switch opts.Color {
14	case ColorOff:
15		fallthrough
16	case ForceColor:
17		return
18	case AutoColor:
19		fi := l.checkWriterIsFile()
20		isUnixTerm := isatty.IsTerminal(fi.Fd())
21		isCygwinTerm := isatty.IsCygwinTerminal(fi.Fd())
22		isTerm := isUnixTerm || isCygwinTerm
23		if !isTerm {
24			l.writer.color = ColorOff
25		}
26	}
27}
28