mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 18:13:54 +08:00
Revert "use forked lumberjack (buffers writes)"
This reverts commit 7055d769582dc852d72c04fab044ca8deb9b3a89.
This commit is contained in:
10
Godeps/Godeps.json
generated
10
Godeps/Godeps.json
generated
@ -262,16 +262,16 @@
|
||||
"ImportPath": "golang.org/x/net/context",
|
||||
"Rev": "ff8eb9a34a5cbb9941ffc6f84a19a8014c2646ad"
|
||||
},
|
||||
{
|
||||
"ImportPath": "gopkg.in/cryptix/lumberjack.v2",
|
||||
"Comment": "v1.0-13-gb9ca6a4",
|
||||
"Rev": "b9ca6a494a971c67b412b38c88ccdbc096d1c9af"
|
||||
},
|
||||
{
|
||||
"ImportPath": "gopkg.in/fsnotify.v1",
|
||||
"Comment": "v1.2.0",
|
||||
"Rev": "96c060f6a6b7e0d6f75fddd10efeaca3e5d1bcb0"
|
||||
},
|
||||
{
|
||||
"ImportPath": "gopkg.in/natefinch/lumberjack.v2",
|
||||
"Comment": "v1.0-12-gd28785c",
|
||||
"Rev": "d28785c2f27cd682d872df46ccd8232843629f54"
|
||||
},
|
||||
{
|
||||
"ImportPath": "gopkg.in/tomb.v1",
|
||||
"Rev": "dd632973f1e7218eb1089048e0798ec9ae7dceb8"
|
||||
|
@ -22,7 +22,6 @@
|
||||
package lumberjack
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@ -95,7 +94,6 @@ type Logger struct {
|
||||
|
||||
size int64
|
||||
file *os.File
|
||||
bw *bufio.Writer
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
@ -139,7 +137,7 @@ func (l *Logger) Write(p []byte) (n int, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
n, err = l.bw.Write(p)
|
||||
n, err = l.file.Write(p)
|
||||
l.size += int64(n)
|
||||
|
||||
return n, err
|
||||
@ -157,11 +155,6 @@ func (l *Logger) close() error {
|
||||
if l.file == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := l.bw.Flush(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := l.file.Close()
|
||||
l.file = nil
|
||||
return err
|
||||
@ -226,7 +219,6 @@ func (l *Logger) openNew() error {
|
||||
return fmt.Errorf("can't open new logfile: %s", err)
|
||||
}
|
||||
l.file = f
|
||||
l.bw = bufio.NewWriter(l.file)
|
||||
l.size = 0
|
||||
return nil
|
||||
}
|
||||
@ -266,7 +258,6 @@ func (l *Logger) openExistingOrNew(writeLen int) error {
|
||||
file, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0644)
|
||||
if err == nil {
|
||||
l.file = file
|
||||
l.bw = bufio.NewWriter(l.file)
|
||||
l.size = info.Size()
|
||||
return nil
|
||||
}
|
@ -41,7 +41,6 @@ func TestNewFile(t *testing.T) {
|
||||
n, err := l.Write(b)
|
||||
isNil(err, t)
|
||||
equals(len(b), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
existsWithLen(logFile(dir), n, t)
|
||||
fileCount(dir, 1, t)
|
||||
}
|
||||
@ -66,7 +65,6 @@ func TestOpenExisting(t *testing.T) {
|
||||
isNil(err, t)
|
||||
equals(len(b), n, t)
|
||||
|
||||
isNil(l.bw.Flush(), t)
|
||||
// make sure the file got appended
|
||||
existsWithLen(filename, len(data)+n, t)
|
||||
|
||||
@ -108,7 +106,6 @@ func TestMakeLogDir(t *testing.T) {
|
||||
n, err := l.Write(b)
|
||||
isNil(err, t)
|
||||
equals(len(b), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
existsWithLen(logFile(dir), n, t)
|
||||
fileCount(dir, 1, t)
|
||||
}
|
||||
@ -125,7 +122,6 @@ func TestDefaultFilename(t *testing.T) {
|
||||
|
||||
isNil(err, t)
|
||||
equals(len(b), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
existsWithLen(filename, n, t)
|
||||
}
|
||||
|
||||
@ -146,7 +142,6 @@ func TestAutoRotate(t *testing.T) {
|
||||
n, err := l.Write(b)
|
||||
isNil(err, t)
|
||||
equals(len(b), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
|
||||
existsWithLen(filename, n, t)
|
||||
fileCount(dir, 1, t)
|
||||
@ -157,7 +152,6 @@ func TestAutoRotate(t *testing.T) {
|
||||
n, err = l.Write(b2)
|
||||
isNil(err, t)
|
||||
equals(len(b2), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
|
||||
// the old logfile should be moved aside and the main logfile should have
|
||||
// only the last write in it.
|
||||
@ -193,7 +187,6 @@ func TestFirstWriteRotate(t *testing.T) {
|
||||
n, err := l.Write(b)
|
||||
isNil(err, t)
|
||||
equals(len(b), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
|
||||
existsWithLen(filename, n, t)
|
||||
existsWithLen(backupFile(dir), len(start), t)
|
||||
@ -218,7 +211,6 @@ func TestMaxBackups(t *testing.T) {
|
||||
n, err := l.Write(b)
|
||||
isNil(err, t)
|
||||
equals(len(b), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
|
||||
existsWithLen(filename, n, t)
|
||||
fileCount(dir, 1, t)
|
||||
@ -230,7 +222,6 @@ func TestMaxBackups(t *testing.T) {
|
||||
n, err = l.Write(b2)
|
||||
isNil(err, t)
|
||||
equals(len(b2), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
|
||||
// this will use the new fake time
|
||||
secondFilename := backupFile(dir)
|
||||
@ -247,7 +238,6 @@ func TestMaxBackups(t *testing.T) {
|
||||
n, err = l.Write(b2)
|
||||
isNil(err, t)
|
||||
equals(len(b2), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
|
||||
// this will use the new fake time
|
||||
thirdFilename := backupFile(dir)
|
||||
@ -290,7 +280,6 @@ func TestMaxBackups(t *testing.T) {
|
||||
n, err = l.Write(b2)
|
||||
isNil(err, t)
|
||||
equals(len(b2), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
|
||||
// this will use the new fake time
|
||||
fourthFilename := backupFile(dir)
|
||||
@ -337,7 +326,6 @@ func TestMaxAge(t *testing.T) {
|
||||
n, err := l.Write(b)
|
||||
isNil(err, t)
|
||||
equals(len(b), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
|
||||
existsWithLen(filename, n, t)
|
||||
fileCount(dir, 1, t)
|
||||
@ -349,7 +337,6 @@ func TestMaxAge(t *testing.T) {
|
||||
n, err = l.Write(b2)
|
||||
isNil(err, t)
|
||||
equals(len(b2), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
existsWithLen(backupFile(dir), len(b), t)
|
||||
|
||||
// we need to wait a little bit since the files get deleted on a different
|
||||
@ -372,7 +359,6 @@ func TestMaxAge(t *testing.T) {
|
||||
n, err = l.Write(b2)
|
||||
isNil(err, t)
|
||||
equals(len(b3), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
existsWithLen(backupFile(dir), len(b2), t)
|
||||
|
||||
// we need to wait a little bit since the files get deleted on a different
|
||||
@ -468,7 +454,6 @@ func TestLocalTime(t *testing.T) {
|
||||
n2, err := l.Write(b2)
|
||||
isNil(err, t)
|
||||
equals(len(b2), n2, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
|
||||
existsWithLen(logFile(dir), n2, t)
|
||||
existsWithLen(backupFileLocal(dir), n, t)
|
||||
@ -491,7 +476,6 @@ func TestRotate(t *testing.T) {
|
||||
n, err := l.Write(b)
|
||||
isNil(err, t)
|
||||
equals(len(b), n, t)
|
||||
isNil(l.bw.Flush(), t)
|
||||
|
||||
existsWithLen(filename, n, t)
|
||||
fileCount(dir, 1, t)
|
||||
@ -527,7 +511,6 @@ func TestRotate(t *testing.T) {
|
||||
n, err = l.Write(b2)
|
||||
isNil(err, t)
|
||||
equals(len(b2), n, t)
|
||||
isNil(l.Close(), t)
|
||||
|
||||
// this will use the new fake time
|
||||
existsWithLen(filename, n, t)
|
2
thirdparty/eventlog/option.go
vendored
2
thirdparty/eventlog/option.go
vendored
@ -5,7 +5,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/Sirupsen/logrus"
|
||||
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/gopkg.in/cryptix/lumberjack.v2"
|
||||
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/gopkg.in/natefinch/lumberjack.v2"
|
||||
)
|
||||
|
||||
// init sets up sane defaults
|
||||
|
Reference in New Issue
Block a user