diff --git a/pkg/logging/logger.go b/pkg/logging/logger.go index ce7d435..95283b4 100644 --- a/pkg/logging/logger.go +++ b/pkg/logging/logger.go @@ -30,6 +30,7 @@ func NewLogger(path string, toStdout bool) (*Logger, error) { func (l *Logger) Println(v ...interface{}) { l.mut.Lock() + defer l.mut.Unlock() nowStr := time.Now().UTC().Format(time.RFC3339) @@ -38,12 +39,11 @@ func (l *Logger) Println(v ...interface{}) { if l.toStdout { fmt.Println(nowStr, v) } - - l.mut.Unlock() } func (l *Logger) Printf(format string, v ...interface{}) { l.mut.Lock() + defer l.mut.Unlock() // Ensure a new line will be written if !strings.HasSuffix(format, "\n") { @@ -57,8 +57,6 @@ func (l *Logger) Printf(format string, v ...interface{}) { if l.toStdout { fmt.Printf(nowStr+" "+format, v...) } - - l.mut.Unlock() } func (l *Logger) Fatalln(v ...interface{}) {