go back to using defer to unlock in close and rotate
This commit is contained in:
+4
-6
@@ -141,9 +141,8 @@ func (l *Logger) Write(p []byte) (n int, err error) {
|
|||||||
// Close implements io.Closer, and closes the current logfile.
|
// Close implements io.Closer, and closes the current logfile.
|
||||||
func (l *Logger) Close() error {
|
func (l *Logger) Close() error {
|
||||||
l.mu.Lock()
|
l.mu.Lock()
|
||||||
err := l.close()
|
defer l.mu.Unlock()
|
||||||
l.mu.Unlock()
|
return l.close()
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// close closes the file if it is open.
|
// close closes the file if it is open.
|
||||||
@@ -163,9 +162,8 @@ func (l *Logger) close() error {
|
|||||||
// to the normal rules.
|
// to the normal rules.
|
||||||
func (l *Logger) Rotate() error {
|
func (l *Logger) Rotate() error {
|
||||||
l.mu.Lock()
|
l.mu.Lock()
|
||||||
err := l.rotate()
|
defer l.mu.Unlock()
|
||||||
l.mu.Unlock()
|
return l.rotate()
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// rotate closes the current file, if any, opens a new file, and then calls
|
// rotate closes the current file, if any, opens a new file, and then calls
|
||||||
|
|||||||
Reference in New Issue
Block a user