func itoa(buf *[]byte, i int, wid int) {
	var b [6]byte
	bp := len(b) - 1
	for i >= 10 || wid > 1 {
		wid--
		q := i / 10
		b[bp] = byte('0' + i - q*10)
		bp--
		i = q
	}
	b[bp] = byte('0' + i)
	*buf = append(*buf, b[bp:]...)
}
Cheap integer to fixed-width decimal ASCII. Give a negative width to avoid zero-padding.
package logs
import (
	"fmt"
	"io"
	"os"
	"sync"
	"time"
)
type logWriter struct {
	sync.Mutex
	writer io.Writer
}
func newLogWriter(wr io.Writer) *logWriter {
	return &logWriter{writer: wr}
}
func (lg *logWriter) println(when time.Time, msg string) {
	lg.Lock()
	h, _ := formatTimeHeader(when)
	lg.writer.Write(append(append(h, msg...), '\n'))
	lg.Unlock()
}
type outputMode int
const (
	_ outputMode = iota
	DiscardNonColorEscSeq
	OutputNonColorEscSeq
)
func NewAnsiColorWriter(w io.Writer) io.Writer {
	return NewModeAnsiColorWriter(w, DiscardNonColorEscSeq)
}
func NewModeAnsiColorWriter(w io.Writer, mode outputMode) io.Writer {
	if _, ok := w.(*ansiColorWriter); !ok {
		return &ansiColorWriter{
			w:    w,
			mode: mode,
		}
	}
	return w
}