Revert "move mutex to unexported field"
This reverts commit 86271c05bd.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
# lumberjack [](https://godoc.org/github.com/natefinch/lumberjack) [](https://travis-ci.org/natefinch/lumberjack)
|
||||
|
||||
# lumberjack [](https://godoc.org/github.com/natefinch/lumberjack)
|
||||
|
||||
[](https://travis-ci.org/natefinch/lumberjack)
|
||||
|
||||
### Lumberjack is a Go package for writing logs to rolling files.
|
||||
|
||||
|
||||
+7
-7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user