feat: add host to access log fields
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
This commit is contained in:
parent
a82fe46fa3
commit
f548c8c8e7
@ -16,6 +16,7 @@ type LogFormatter struct{}
|
||||
func (*LogFormatter) NewLogEntry(r *http.Request) middleware.LogEntry {
|
||||
return &LogEntry{
|
||||
method: r.Method,
|
||||
host: r.Host,
|
||||
path: r.URL.Path,
|
||||
ctx: r.Context(),
|
||||
}
|
||||
@ -29,6 +30,7 @@ var _ middleware.LogFormatter = &LogFormatter{}
|
||||
|
||||
type LogEntry struct {
|
||||
method string
|
||||
host string
|
||||
path string
|
||||
ctx context.Context
|
||||
}
|
||||
@ -41,6 +43,7 @@ func (e *LogEntry) Panic(v interface{}, stack []byte) {
|
||||
// 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.F("host", e.host),
|
||||
logger.F("status", status),
|
||||
logger.F("bytes", bytes),
|
||||
logger.F("elapsed", elapsed),
|
||||
|
Loading…
Reference in New Issue
Block a user