fixes go-vet error: Format passes lock by value

remotes/origin/HEAD
Guoqiang Chen 7 years ago
parent 290a8a5fac
commit b8c295e6f7

@ -15,7 +15,7 @@ type simpleFormatter struct {
} }
// Format implements log.Formatter // Format implements log.Formatter
func (f simpleFormatter) Format(level Level, msg string, logger *Logger) []byte { func (f *simpleFormatter) Format(level Level, msg string, logger *Logger) []byte {
time := time.Now().Format("15:04:05.000") time := time.Now().Format("15:04:05.000")
return []byte(fmt.Sprintf("%s %s %s\n", time, level.String(), msg)) return []byte(fmt.Sprintf("%s %s %s\n", time, level.String(), msg))
} }

@ -23,7 +23,7 @@ type JSONFormatter struct {
} }
// Format implements log.Formatter // Format implements log.Formatter
func (f JSONFormatter) Format(level log.Level, msg string, logger *log.Logger) []byte { func (f *JSONFormatter) Format(level log.Level, msg string, logger *log.Logger) []byte {
// output fields: time level host app pid file line msg // output fields: time level host app pid file line msg
f.init.Do(func() { f.init.Do(func() {

@ -32,7 +32,7 @@ type TextFormatter struct {
} }
// Format implements log.Formatter // Format implements log.Formatter
func (f TextFormatter) Format(level log.Level, msg string, logger *log.Logger) []byte { func (f *TextFormatter) Format(level log.Level, msg string, logger *log.Logger) []byte {
// output format: DATE LEVEL HOST APP PID file:line message // output format: DATE LEVEL HOST APP PID file:line message
// 2001-10-10T12:00:00,000+0800 INFO web-1 app 1234 main/main.go:1234 message ... // 2001-10-10T12:00:00,000+0800 INFO web-1 app 1234 main/main.go:1234 message ...

Loading…
Cancel
Save