func (l *logger) traceRequest(req *http.Request, status, size int, start time.Time) {
	url := req.URL
	host, _, err := net.SplitHostPort(req.RemoteAddr)
	if err != nil {
		host = req.RemoteAddr
	}
	uri := req.RequestURI
	if uri == "" {
		uri = url.RequestURI()
	}
	l.Tracef(`%s - "%s %s %s" %d %d %.6f`,
		host, req.Method, uri, req.Proto, status, size, time.Since(start).Seconds())
}
traceRequests generates an access log for the request.
package server
import (
	"fmt"
	"log"
	"net"
	"net/http"
	"os"
	"time"
)
type logger struct {
	logger     *log.Logger
	debug      bool
	trace      bool
	infoLabel  string
	warnLabel  string
	errorLabel string
	fatalLabel string
	debugLabel string
	traceLabel string
	rotate     func() error
}
func NewLogger(opts *Options) *logger {
	prefix := fmt.Sprintf("[%d] ", os.Getpid())
	flags := log.LstdFlags | log.Lmicroseconds
	l := &logger{logger: log.New(os.Stderr, prefix, flags)}
	if opts.NoColors {
		l.debugLabel = "[DBG] "
		l.traceLabel = "[TRC] "
		l.infoLabel = "[INF] "
		l.warnLabel = "[WRN] "
		l.errorLabel = "[ERR] "
	} else {
		colorFormat := "[\x1b[%sm%s\x1b[0m] "
		l.debugLabel = fmt.Sprintf(colorFormat, "36", "DBG")
		l.traceLabel = fmt.Sprintf(colorFormat, "33", "TRC")
		l.infoLabel = fmt.Sprintf(colorFormat, "32", "INF")
		l.warnLabel = fmt.Sprintf(colorFormat, "0;93", "WRN")
		l.errorLabel = fmt.Sprintf(colorFormat, "31", "ERR")
	}
	return l
}
func (l *logger) Infof(format string, v ...interface{}) {
	l.logger.Printf(l.infoLabel+format, v...)
}
func (l *logger) Warnf(format string, v ...interface{}) {
	l.logger.Printf(l.warnLabel+format, v...)
}
func (l *logger) Errorf(format string, v ...interface{}) {
	l.logger.Printf(l.errorLabel+format, v...)
}
func (l *logger) Debugf(format string, v ...interface{}) {
	if l.debug {
		l.logger.Printf(l.debugLabel+format, v...)
	}
}
func (l *logger) Tracef(format string, v ...interface{}) {
	if l.trace {
		l.logger.Printf(l.traceLabel+format, v...)
	}
}