feat: do not use fmt.Sprintf in http logger
This commit is contained in:
parent
be59be1795
commit
910f1f8ba2
@ -2,7 +2,6 @@ package chi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@ -37,12 +36,19 @@ type LogEntry struct {
|
||||
|
||||
// Panic implements middleware.LogEntry
|
||||
func (e *LogEntry) Panic(v interface{}, stack []byte) {
|
||||
logger.Error(e.ctx, fmt.Sprintf("%s %s", e.method, e.path), logger.F("stack", string(stack)))
|
||||
logger.Error(
|
||||
e.ctx, "http panic",
|
||||
logger.F("stack", string(stack)),
|
||||
logger.F("host", e.host),
|
||||
logger.F("method", e.method),
|
||||
logger.F("path", e.path),
|
||||
)
|
||||
}
|
||||
|
||||
// Write implements middleware.LogEntry
|
||||
func (e *LogEntry) Write(status int, bytes int, header http.Header, elapsed time.Duration, extra interface{}) {
|
||||
logger.Info(e.ctx, fmt.Sprintf("%s %s - %d", e.method, e.path, status),
|
||||
logger.Info(
|
||||
e.ctx, "http request",
|
||||
logger.F("host", e.host),
|
||||
logger.F("status", status),
|
||||
logger.F("bytes", bytes),
|
||||
|
Loading…
Reference in New Issue
Block a user