// Run retrieves the debug log via the API. func (c *debugLogCommand) Run(ctx *cmd.Context) (err error) { if c.tail { c.params.NoTail = false } else if c.notail { c.params.NoTail = true } else { // Set the default tail option to true if the caller is // using a terminal. c.params.NoTail = !isTerminal(ctx.Stdout) } client, err := getDebugLogAPI(c) if err != nil { return err } defer client.Close() messages, err := client.WatchDebugLog(c.params) if err != nil { return err } writer := ansiterm.NewWriter(ctx.Stdout) if c.color { writer.SetColorCapable(true) } for { msg, ok := <-messages if !ok { break } c.writeLogRecord(writer, msg) } return nil }
// NewColorWriter will write out colored severity levels if the writer is // outputting to a terminal. func NewWarningWriter(writer io.Writer) loggo.Writer { w := &warningWriter{ansiterm.NewWriter(writer)} return loggo.NewMinimumLevelWriter(w, loggo.WARNING) }
// NewColorWriter will write out colored severity levels if the writer is // outputting to a terminal. func NewColorWriter(writer io.Writer) Writer { return &colorWriter{ansiterm.NewWriter(writer)} }