remove deprecated log.Event calls

上级 4a102207
......@@ -11,14 +11,13 @@ import (
logging "github.com/ipfs/go-log"
"github.com/jbenet/goprocess"
"github.com/jbenet/goprocess/context"
"github.com/jbenet/goprocess/periodic"
goprocessctx "github.com/jbenet/goprocess/context"
periodicproc "github.com/jbenet/goprocess/periodic"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
"github.com/libp2p/go-libp2p-core/routing"
"github.com/libp2p/go-libp2p-loggables"
)
var log = logging.Logger("bootstrap")
......@@ -73,7 +72,6 @@ func BootstrapConfigWithPeers(pis []peer.AddrInfo) BootstrapConfig {
// connections to well-known bootstrap peers. It also kicks off subsystem
// bootstrapping (i.e. routing).
func Bootstrap(id peer.ID, host host.Host, rt routing.Routing, cfg BootstrapConfig) (io.Closer, error) {
// make a signal to wait for one bootstrap round to complete.
doneWithRound := make(chan struct{})
......@@ -86,11 +84,9 @@ func Bootstrap(id peer.ID, host host.Host, rt routing.Routing, cfg BootstrapConf
// the periodic bootstrap function -- the connection supervisor
periodic := func(worker goprocess.Process) {
ctx := goprocessctx.OnClosingContext(worker)
defer log.EventBegin(ctx, "periodicBootstrap", id).Done()
if err := bootstrapRound(ctx, host, cfg); err != nil {
log.Event(ctx, "bootstrapError", id, loggables.Error(err))
log.Debugf("%s bootstrap error: %s", id, err)
log.Errorf("%s bootstrap error: %s", id, err)
}
<-doneWithRound
......@@ -115,7 +111,6 @@ func Bootstrap(id peer.ID, host host.Host, rt routing.Routing, cfg BootstrapConf
}
func bootstrapRound(ctx context.Context, host host.Host, cfg BootstrapConfig) error {
ctx, cancel := context.WithTimeout(ctx, cfg.ConnectionTimeout)
defer cancel()
id := host.ID()
......@@ -126,9 +121,11 @@ func bootstrapRound(ctx context.Context, host host.Host, cfg BootstrapConfig) er
// determine how many bootstrap connections to open
connected := host.Network().Peers()
if len(connected) >= cfg.MinPeerThreshold {
log.Event(ctx, "bootstrapSkip", id)
log.Debugf("%s core bootstrap skipped -- connected to %d (> %d) nodes",
id, len(connected), cfg.MinPeerThreshold)
id,
len(connected),
cfg.MinPeerThreshold,
)
return nil
}
numToDial := cfg.MinPeerThreshold - len(connected)
......@@ -150,7 +147,6 @@ func bootstrapRound(ctx context.Context, host host.Host, cfg BootstrapConfig) er
// connect to a random susbset of bootstrap candidates
randSubset := randomSubsetOfPeers(notConnected, numToDial)
defer log.EventBegin(ctx, "bootstrapStart", id).Done()
log.Debugf("%s bootstrapping to %d nodes: %s", id, numToDial, randSubset)
return bootstrapConnect(ctx, host, randSubset)
}
......@@ -172,18 +168,26 @@ func bootstrapConnect(ctx context.Context, ph host.Host, peers []peer.AddrInfo)
wg.Add(1)
go func(p peer.AddrInfo) {
defer wg.Done()
defer log.EventBegin(ctx, "bootstrapDial", ph.ID(), p.ID).Done()
log.Debugf("%s bootstrapping to %s", ph.ID(), p.ID)
log.Infow("dial bootstrap peer begun",
"host", ph.ID(),
"bootstrap_peer", p.ID,
)
ph.Peerstore().AddAddrs(p.ID, p.Addrs, peerstore.PermanentAddrTTL)
if err := ph.Connect(ctx, p); err != nil {
log.Event(ctx, "bootstrapDialFailed", p.ID)
log.Debugf("failed to bootstrap with %v: %s", p.ID, err)
log.Errorw("dial bootstrap peer failed",
"host", ph.ID(),
"bootstrap_peer", p.ID,
"error", err,
)
errs <- err
return
}
log.Event(ctx, "bootstrapDialSuccess", p.ID)
log.Infof("bootstrapped with %v", p.ID)
log.Infow("dial bootstrap peer success",
"host", ph.ID(),
"bootstrap_peer", p.ID,
)
}(p)
}
wg.Wait()
......
......@@ -53,7 +53,7 @@ func addCORSFromEnv(c *cmdsHttp.ServerConfig) {
}
func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) {
log.Info("Using API.HTTPHeaders:", nc.API.HTTPHeaders)
log.Infow("Using API.HTTPHeaders", "headers", nc.API.HTTPHeaders)
if acao := nc.API.HTTPHeaders[cmdsHttp.ACAOrigin]; acao != nil {
c.SetAllowedOrigins(acao...)
......
......@@ -50,7 +50,6 @@ func LogOption() ServeOption {
w.WriteHeader(200)
wnf, errs := newWriteErrNotifier(w)
lwriter.WriterGroup.AddWriter(wnf)
log.Event(n.Context(), "log API client connected")
<-errs
})
return mux, nil
......
......@@ -217,7 +217,6 @@ func (gc *GC) maybeGC(ctx context.Context, offset uint64) error {
// Do GC here
log.Info("Watermark exceeded. Starting repo GC...")
defer log.EventBegin(ctx, "repoGC").Done()
if err := GarbageCollect(gc.Node, ctx); err != nil {
return err
......
......@@ -246,7 +246,6 @@ func (s *Node) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadR
lm["key"] = func() interface{} { return c.String() }
lm["req_offset"] = req.Offset
lm["req_size"] = req.Size
defer log.EventBegin(ctx, "fuseRead", lm).Done()
r, err := uio.NewDagReader(ctx, s.Nd, s.Ipfs.DAG)
if err != nil {
......
......@@ -43,7 +43,7 @@ require (
github.com/ipfs/go-ipld-format v0.0.2
github.com/ipfs/go-ipld-git v0.0.2
github.com/ipfs/go-ipns v0.0.1
github.com/ipfs/go-log v0.0.1
github.com/ipfs/go-log v0.0.2-0.20190920042044-a609c1ae5144
github.com/ipfs/go-merkledag v0.2.3
github.com/ipfs/go-metrics-interface v0.0.1
github.com/ipfs/go-metrics-prometheus v0.0.2
......@@ -96,11 +96,10 @@ require (
github.com/whyrusleeping/go-sysinfo v0.0.0-20190219211824-4a357d4b90b1
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7
github.com/whyrusleeping/tar-utils v0.0.0-20180509141711-8c6c8ba81d5c
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/dig v1.7.0 // indirect
go.uber.org/fx v1.9.0
go.uber.org/goleak v0.10.0 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.10.0
go4.org v0.0.0-20190313082347-94abd6928b1d // indirect
golang.org/x/crypto v0.0.0-20190926180335-cea2066c6411 // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
......
......@@ -227,6 +227,10 @@ github.com/ipfs/go-ipns v0.0.1 h1:5vX0+ehF55YWxE8Pmf4eB8szcP+fh24AXnvCkOmSLCc=
github.com/ipfs/go-ipns v0.0.1/go.mod h1:HOiAXgGiH0wCSwsFM1IKdOy6YGT4iZafcsUKni703/g=
github.com/ipfs/go-log v0.0.1 h1:9XTUN/rW64BCG1YhPK9Hoy3q8nr4gOmHHBpgFdfw6Lc=
github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM=
github.com/ipfs/go-log v0.0.2-0.20190919062756-9da87eb98e24 h1:eLr4BqUWa7TlrphmtstEiVbpprAmqULh0/tAw7WMmSE=
github.com/ipfs/go-log v0.0.2-0.20190919062756-9da87eb98e24/go.mod h1:azGN5dH7ailfREknDDNYB0Eq4qZ/4I4Y3gO0ivjJNyM=
github.com/ipfs/go-log v0.0.2-0.20190920042044-a609c1ae5144 h1:5WM8S1nwquWQ3zEuNhK82NE5Di6Pd41qz9JxxvxTAIA=
github.com/ipfs/go-log v0.0.2-0.20190920042044-a609c1ae5144/go.mod h1:azGN5dH7ailfREknDDNYB0Eq4qZ/4I4Y3gO0ivjJNyM=
github.com/ipfs/go-merkledag v0.0.3/go.mod h1:Oc5kIXLHokkE1hWGMBHw+oxehkAaTOqtEb7Zbh6BhLA=
github.com/ipfs/go-merkledag v0.0.6/go.mod h1:QYPdnlvkOg7GnQRofu9XZimC5ZW5Wi3bKys/4GQQfto=
github.com/ipfs/go-merkledag v0.1.0/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk=
......@@ -627,6 +631,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e h1:T5PdfK/M1xyrHwynxMIVMWLS7f/qHwfslZphxtGnw7s=
......@@ -678,6 +683,8 @@ go.uber.org/goleak v0.10.0 h1:G3eWbSNIskeRqtsN/1uI5B+eP73y3JUuBsv9AZjehb4=
go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI=
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go4.org v0.0.0-20190218023631-ce4c26f7be8e/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
go4.org v0.0.0-20190313082347-94abd6928b1d h1:JkRdGP3zvTtTbabWSAC6n67ka30y7gOzWAah4XYJSfw=
go4.org v0.0.0-20190313082347-94abd6928b1d/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
......
......@@ -6,7 +6,7 @@ import (
"fmt"
"strings"
"github.com/ipfs/go-ipld-format"
format "github.com/ipfs/go-ipld-format"
logging "github.com/ipfs/go-log"
"github.com/ipfs/go-path"
"github.com/ipfs/go-path/resolver"
......@@ -24,8 +24,6 @@ var ErrNoNamesys = errors.New(
// ResolveIPNS resolves /ipns paths
func ResolveIPNS(ctx context.Context, nsys namesys.NameSystem, p path.Path) (path.Path, error) {
if strings.HasPrefix(p.String(), "/ipns/") {
evt := log.EventBegin(ctx, "resolveIpnsPath")
defer evt.Done()
// resolve ipns paths
// TODO(cryptix): we should be able to query the local cache for the path
......
......@@ -40,13 +40,10 @@ type Result struct {
// deletes any block that is not found in the marked set.
func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn pin.Pinner, bestEffortRoots []cid.Cid) <-chan Result {
ctx, cancel := context.WithCancel(ctx)
//TODO(lanzafame): add tracing
elock := log.EventBegin(ctx, "GC.lockWait")
log.Info("beginning GC")
unlocker := bs.GCLock()
elock.Done()
elock = log.EventBegin(ctx, "GC.locked")
emark := log.EventBegin(ctx, "GC.mark")
bsrv := bserv.New(bs, offline.Exchange(bs))
ds := dag.NewDAGService(bsrv)
......@@ -56,7 +53,6 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
defer cancel()
defer close(output)
defer unlocker.Unlock()
defer elock.Done()
gcs, err := ColoredSet(ctx, pn, ds, bestEffortRoots, output)
if err != nil {
......@@ -66,11 +62,6 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
}
return
}
emark.Append(logging.LoggableMap{
"blackSetSize": fmt.Sprintf("%d", gcs.Len()),
})
emark.Done()
esweep := log.EventBegin(ctx, "GC.sweep")
keychan, err := bs.AllKeysChan(ctx)
if err != nil {
......@@ -114,10 +105,6 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
break loop
}
}
esweep.Append(logging.LoggableMap{
"whiteSetSize": fmt.Sprintf("%d", removed),
})
esweep.Done()
if errors {
select {
case output <- Result{Error: ErrCannotDeleteSomeBlocks}:
......@@ -126,7 +113,6 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
}
}
defer log.EventBegin(ctx, "GC.datastore").Done()
gds, ok := dstor.(dstore.GCDatastore)
if !ok {
return
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论