Example #1
0
// Just set the color flag if it seems like TTY
func (f *stdformatter) UnsyncedAutoColoring() {
	var istty bool
	w := f.out
	if tw, ok := w.(MaybeTtyWriter); ok {
		istty = tw.IsTty()
	} else {
		istty = term.IsTty(w)
	}

	if istty {
		f.flag = f.flag | Lcolor
	} else {
		f.flag = f.flag & ^Lcolor
	}
}
Example #2
0
func (f *flxformatter) UnsyncedAutoColoring() {
	var istty bool
	w := f.out
	if tw, ok := w.(MaybeTtyWriter); ok {
		istty = tw.IsTty()
	} else {
		istty = term.IsTty(w)
	}

	if istty {
		f.SetLevelPrefixes(&term_lvlpfx)
		f.flag = f.flag | Lcolor
	} else {
		f.flag = f.flag & ^Lcolor
	}
}
Example #3
0
// Generate options to create a new Handler
func (f *stdformatter) AutoColoring() HandlerOption {
	return func(c CloneableHandler) {
		var istty bool
		if o, ok := c.(*stdformatter); ok {
			w := o.out
			if tw, ok := w.(MaybeTtyWriter); ok {
				istty = tw.IsTty()
			} else {
				istty = term.IsTty(w)
			}

			if istty {
				o.flag = o.flag | Lcolor
			} else {
				o.flag = o.flag & ^Lcolor
			}
		}
	}
}