From 06f4f4ea5e2f6cb5931e9e2b3f4ee188998c743c Mon Sep 17 00:00:00 2001 From: Nate Finch Date: Mon, 16 Jun 2014 15:29:37 -0400 Subject: [PATCH] go back to using defer to unlock in close and rotate --- lumberjack.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lumberjack.go b/lumberjack.go index 69fa32a..b436e16 100644 --- a/lumberjack.go +++ b/lumberjack.go @@ -141,9 +141,8 @@ func (l *Logger) Write(p []byte) (n int, err error) { // Close implements io.Closer, and closes the current logfile. func (l *Logger) Close() error { l.mu.Lock() - err := l.close() - l.mu.Unlock() - return err + defer l.mu.Unlock() + return l.close() } // close closes the file if it is open. @@ -163,9 +162,8 @@ func (l *Logger) close() error { // to the normal rules. func (l *Logger) Rotate() error { l.mu.Lock() - err := l.rotate() - l.mu.Unlock() - return err + defer l.mu.Unlock() + return l.rotate() } // rotate closes the current file, if any, opens a new file, and then calls