Start using new log package
This commit is contained in:
parent
5ef22a978b
commit
53e32ca9dd
|
@ -8,13 +8,14 @@ import (
|
|||
"expvar"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/anacrolix/log"
|
||||
|
||||
"github.com/anacrolix/dht"
|
||||
"github.com/anacrolix/dht/krpc"
|
||||
"github.com/anacrolix/missinggo"
|
||||
|
@ -1040,6 +1041,7 @@ func (cl *Client) newTorrent(ih metainfo.Hash, specStorage storage.ClientImpl) (
|
|||
L: &cl.mu,
|
||||
},
|
||||
}
|
||||
t.logger = log.Default.Clone().AddValue(t)
|
||||
t.setChunkSize(defaultChunkSize)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import (
|
|||
_ "github.com/anacrolix/envpprof"
|
||||
"github.com/anacrolix/missinggo"
|
||||
"github.com/anacrolix/missinggo/filecache"
|
||||
"github.com/anacrolix/missinggo/pubsub"
|
||||
"github.com/bradfitz/iter"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -100,14 +99,12 @@ func TestPieceHashSize(t *testing.T) {
|
|||
func TestTorrentInitialState(t *testing.T) {
|
||||
dir, mi := testutil.GreetingTestTorrent()
|
||||
defer os.RemoveAll(dir)
|
||||
tor := &Torrent{
|
||||
infoHash: mi.HashInfoBytes(),
|
||||
pieceStateChanges: pubsub.NewPubSub(),
|
||||
}
|
||||
tor.chunkSize = 2
|
||||
tor.storageOpener = storage.NewClient(storage.NewFileWithCompletion(tempDir(), storage.NewMapPieceCompletion()))
|
||||
// Needed to lock for asynchronous piece verification.
|
||||
tor.cl = new(Client)
|
||||
cl := &Client{}
|
||||
tor := cl.newTorrent(
|
||||
mi.HashInfoBytes(),
|
||||
storage.NewFileWithCompletion(tempDir(), storage.NewMapPieceCompletion()),
|
||||
)
|
||||
tor.setChunkSize(2)
|
||||
tor.cl.mu.Lock()
|
||||
err := tor.setInfoBytes(mi.InfoBytes)
|
||||
tor.cl.mu.Unlock()
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"math"
|
||||
"math/rand"
|
||||
"net"
|
||||
|
@ -16,6 +15,8 @@ import (
|
|||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"github.com/anacrolix/log"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
|
||||
"github.com/anacrolix/dht"
|
||||
|
@ -46,6 +47,7 @@ type peersKey struct {
|
|||
// Maintains state of torrent within a Client.
|
||||
type Torrent struct {
|
||||
cl *Client
|
||||
logger *log.Logger
|
||||
|
||||
networkingEnabled bool
|
||||
// Determines what chunks to request from peers. 1: Favour higher priority
|
||||
|
|
|
@ -146,12 +146,9 @@ func TestEmptyFilesAndZeroPieceLengthWithMMapStorage(t *testing.T) {
|
|||
|
||||
func TestPieceHashFailed(t *testing.T) {
|
||||
mi := testutil.GreetingMetaInfo()
|
||||
tt := Torrent{
|
||||
cl: new(Client),
|
||||
infoHash: mi.HashInfoBytes(),
|
||||
storageOpener: storage.NewClient(badStorage{}),
|
||||
chunkSize: 2,
|
||||
}
|
||||
cl := new(Client)
|
||||
tt := cl.newTorrent(mi.HashInfoBytes(), badStorage{})
|
||||
tt.setChunkSize(2)
|
||||
require.NoError(t, tt.setInfoBytes(mi.InfoBytes))
|
||||
tt.cl.mu.Lock()
|
||||
tt.pieces[1].dirtyChunks.AddRange(0, 3)
|
||||
|
|
Loading…
Reference in New Issue