From c5ffa6702e731710784b60686db486fee96bb872 Mon Sep 17 00:00:00 2001 From: Will Faught Date: Sat, 14 Jan 2017 00:59:00 -0800 Subject: [PATCH 1/2] Rename file term to caller --- log/stdlib.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/log/stdlib.go b/log/stdlib.go index 7ffd1ca17..ea79738c8 100644 --- a/log/stdlib.go +++ b/log/stdlib.go @@ -27,7 +27,7 @@ func (w StdlibWriter) Write(p []byte) (int, error) { type StdlibAdapter struct { Logger timestampKey string - fileKey string + callerKey string messageKey string } @@ -39,9 +39,9 @@ func TimestampKey(key string) StdlibAdapterOption { return func(a *StdlibAdapter) { a.timestampKey = key } } -// FileKey sets the key for the file and line field. By default, it's "file". -func FileKey(key string) StdlibAdapterOption { - return func(a *StdlibAdapter) { a.fileKey = key } +// CallerKey sets the key for the file and line field. By default, it's "caller". +func CallerKey(key string) StdlibAdapterOption { + return func(a *StdlibAdapter) { a.callerKey = key } } // MessageKey sets the key for the actual log message. By default, it's "msg". @@ -55,7 +55,7 @@ func NewStdlibAdapter(logger Logger, options ...StdlibAdapterOption) io.Writer { a := StdlibAdapter{ Logger: logger, timestampKey: "ts", - fileKey: "file", + callerKey "caller", messageKey: "msg", } for _, option := range options { @@ -80,8 +80,8 @@ func (a StdlibAdapter) Write(p []byte) (int, error) { if timestamp != "" { keyvals = append(keyvals, a.timestampKey, timestamp) } - if file, ok := result["file"]; ok && file != "" { - keyvals = append(keyvals, a.fileKey, file) + if caller, ok := result["caller"]; ok && caller != "" { + keyvals = append(keyvals, a.callerKey, caller) } if msg, ok := result["msg"]; ok { keyvals = append(keyvals, a.messageKey, msg) @@ -93,14 +93,14 @@ func (a StdlibAdapter) Write(p []byte) (int, error) { } const ( - logRegexpDate = `(?P[0-9]{4}/[0-9]{2}/[0-9]{2})?[ ]?` - logRegexpTime = `(?P