middleware/logger.go
func (l *DefaultLogFormatter) NewLogEntry(r *http.Request) LogEntry {
	useColor := !l.NoColor
	entry := &defaultLogEntry{
		DefaultLogFormatter: l,
		request:             r,
		buf:                 &bytes.Buffer{},
		useColor:            useColor,
	}

	reqID := GetReqID(r.Context())
	if reqID != "" {
		cW(entry.buf, useColor, nYellow, "[%s] ", reqID)
	}
	cW(entry.buf, useColor, nCyan, "\"")
	cW(entry.buf, useColor, bMagenta, "%s ", r.Method)

	scheme := "http"
	if r.TLS != nil {
		scheme = "https"
	}
	cW(entry.buf, useColor, nCyan, "%s://%s%s %s\" ", scheme, r.Host, r.RequestURI, r.Proto)

	entry.buf.WriteString("from ")
	entry.buf.WriteString(r.RemoteAddr)
	entry.buf.WriteString(" - ")

	return entry
}
func (l *DefaultLogFormatter) NewLogEntry(r *http.Request) LogEntry {
	useColor := !l.NoColor
	entry := &defaultLogEntry{
		DefaultLogFormatter: l,
		request:             r,
		buf:                 &bytes.Buffer{},
		useColor:            useColor,
	}

	reqID := GetReqID(r.Context())
	if reqID != "" {
		cW(entry.buf, useColor, nYellow, "[%s] ", reqID)
	}
	cW(entry.buf, useColor, nCyan, "\"")
	cW(entry.buf, useColor, bMagenta, "%s ", r.Method)

	scheme := "http"
	if r.TLS != nil {
		scheme = "https"
	}
	cW(entry.buf, useColor, nCyan, "%s://%s%s %s\" ", scheme, r.Host, r.RequestURI, r.Proto)

	entry.buf.WriteString("from ")
	entry.buf.WriteString(r.RemoteAddr)
	entry.buf.WriteString(" - ")

	return entry
}
func ( l * DefaultLogFormatter ) NewLogEntry ( r * http . Request ) LogEntry { useColor := ! l . NoColor entry := & defaultLogEntry { DefaultLogFormatter : l , request : r , buf : & bytes . Buffer { } , useColor : useColor , } reqID := GetReqID ( r . Context ( ) ) if reqID != " " { cW ( entry . buf , useColor , nYellow , " " , reqID ) } cW ( entry . buf , useColor , nCyan , " \" " ) cW ( entry . buf , useColor , bMagenta , " " , r . Method ) scheme := " " if r . TLS != nil { scheme = " " } cW ( entry . buf , useColor , nCyan , " \" " , scheme , r . Host , r . RequestURI , r . Proto ) entry . buf . WriteString ( " " ) entry . buf . WriteString ( r . RemoteAddr ) entry . buf . WriteString ( " " ) return entry }
// NewLogEntry creates a new LogEntry for the request.
NewLogEntry creates a new LogEntry for the request .