mirror of
https://github.com/adnanh/webhook.git
synced 2025-06-02 10:42:28 +00:00
Merge pull request #432 from moorereason/bugfix/logging-gocritic
Fix issues in logging middleware
This commit is contained in:
commit
c4f29b5d8b
1 changed files with 3 additions and 3 deletions
|
@ -39,18 +39,18 @@ type LogEntry struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write constructs and writes the final log entry.
|
// Write constructs and writes the final log entry.
|
||||||
func (l *LogEntry) Write(status, bytes int, elapsed time.Duration) {
|
func (l *LogEntry) Write(status, totalBytes int, elapsed time.Duration) {
|
||||||
rid := GetReqID(l.req.Context())
|
rid := GetReqID(l.req.Context())
|
||||||
if rid != "" {
|
if rid != "" {
|
||||||
fmt.Fprintf(l.buf, "[%s] ", rid)
|
fmt.Fprintf(l.buf, "[%s] ", rid)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(l.buf, "%03d | %s | %s | ", status, humanize.IBytes(uint64(bytes)), elapsed)
|
fmt.Fprintf(l.buf, "%03d | %s | %s | ", status, humanize.IBytes(uint64(totalBytes)), elapsed)
|
||||||
l.buf.WriteString(l.req.Host + " | " + l.req.Method + " " + l.req.RequestURI)
|
l.buf.WriteString(l.req.Host + " | " + l.req.Method + " " + l.req.RequestURI)
|
||||||
log.Print(l.buf.String())
|
log.Print(l.buf.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Panic prints the call stack for a panic.
|
// Panic prints the call stack for a panic.
|
||||||
func (l *LogEntry) Panic(v interface{}, stack []byte) {
|
func (l *LogEntry) Panic(v interface{}, stack []byte) {
|
||||||
e := l.NewLogEntry(l.req).(*LogEntry)
|
e := l.NewLogEntry(l.req).(*LogEntry)
|
||||||
fmt.Fprintf(e.buf, "panic: %#v", v)
|
fmt.Fprintf(e.buf, "panic: %#v", v)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue