Golang Writer.Fd Examples

Golang Writer.Fd - 5 examples found. These are the top rated real world Golang examples of io.Writer.Fd extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
func (l *Logger) SetOutput(w io.Writer) {
	l.output = w
	l.DisableColor()

	if w, ok := w.(*os.File); ok && isatty.IsTerminal(w.Fd()) {
		l.EnableColor()
	}
}
Example #2
0
File: log.go Project: o1egl/gommon
func (l *Logger) SetOutput(w io.Writer) {
	l.out = w
	color.Disable()

	if w, ok := w.(*os.File); ok && isatty.IsTerminal(w.Fd()) {
		color.Enable()
	}

	// NOTE: Reintialize levels to reflect color enable/disable call.
	initLevels()
}
Example #3
0
func (l *Logger) SetOutput(w io.Writer) {
	l.out = w
	l.err = w

	switch w := w.(type) {
	case *os.File:
		if isatty.IsTerminal(w.Fd()) {
			color.Enable()
		}
	default:
		color.Disable()
	}

	// NOTE: Reintialize levels to reflect color enable/disable call.
	initLevels()
}
Example #4
0
File: log.go Project: mattn/gommon
func (l *Logger) SetOutput(w io.Writer) {
	l.out = w
	l.err = w
	color.Disable()

	switch w := w.(type) {
	case *os.File:
		if isatty.IsTerminal(w.Fd()) {
			color.Enable()
		}
		levels = []string{
			color.Cyan("TRACE"),
			color.Blue("DEBUG"),
			color.Green("INFO"),
			color.Magenta("NOTICE"),
			color.Yellow("WARN"),
			color.Red("ERROR"),
			color.RedBg("FATAL"),
		}
	}
}
Example #5
0
// SetOutput sets the output.
func (c *Color) SetOutput(w io.Writer) {
	c.output = w
	if w, ok := w.(*os.File); !ok || !isatty.IsTerminal(w.Fd()) {
		c.disabled = true
	}
}