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