2
0

Revert "move mutex to unexported field"

This reverts commit 86271c05bd.
This commit is contained in:
Nate Finch
2014-06-16 06:54:51 -04:00
2 changed files with 9 additions and 9 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
# lumberjack [![GoDoc](https://godoc.org/github.com/natefinch/lumberjack?status.png)](https://godoc.org/github.com/natefinch/lumberjack) [![Build Status](https://travis-ci.org/natefinch/lumberjack.png)](https://travis-ci.org/natefinch/lumberjack)
# lumberjack [![GoDoc](https://godoc.org/github.com/natefinch/lumberjack?status.png)](https://godoc.org/github.com/natefinch/lumberjack)
[![Build Status](https://travis-ci.org/natefinch/lumberjack.png)](https://travis-ci.org/natefinch/lumberjack)
### Lumberjack is a Go package for writing logs to rolling files.
+7 -7
View File
@@ -110,7 +110,7 @@ type Logger struct {
size int64
file *os.File
mu sync.Mutex
sync.Mutex
}
// currentTime is only used for testing. Normally it's the time.Now() function.
@@ -121,8 +121,8 @@ var currentTime = time.Now
// PathFormat. If the length of the write is greater than MaxSize, an error is
// returned that satisfies IsWriteTooLong.
func (l *Logger) Write(p []byte) (n int, err error) {
l.mu.Lock()
defer l.mu.Unlock()
l.Lock()
defer l.Unlock()
writeLen := int64(len(p))
if writeLen > l.max() {
return 0, fmt.Errorf(
@@ -160,8 +160,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()
defer l.mu.Unlock()
l.Lock()
defer l.Unlock()
if l.file != nil {
err := l.file.Close()
l.file = nil
@@ -176,8 +176,8 @@ func (l *Logger) Close() error {
// SIGHUP. After rotating, this initiates a cleanup of old log files according
// to the normal rules.
func (l *Logger) Rotate() error {
l.mu.Lock()
defer l.mu.Unlock()
l.Lock()
defer l.Unlock()
if l.file != nil {
if err := l.file.Close(); err != nil {
return err