diff --git a/markets/loggers/loggers.go b/markets/loggers/loggers.go index a8e1c20aa6..87c8dfe65a 100644 --- a/markets/loggers/loggers.go +++ b/markets/loggers/loggers.go @@ -1,6 +1,7 @@ package marketevents import ( + datatransfer "github.com/filecoin-project/go-data-transfer" "github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" @@ -29,6 +30,23 @@ func RetrievalProviderLogger(event retrievalmarket.ProviderEvent, deal retrieval log.Infow("retrieval event", "name", retrievalmarket.ProviderEvents[event], "deal ID", deal.ID, "receiver", deal.Receiver, "state", retrievalmarket.DealStatuses[deal.Status], "message", deal.Message) } +// DataTransferLogger logs events from the data transfer module +func DataTransferLogger(event datatransfer.Event, state datatransfer.ChannelState) { + log.Debugw("data transfer event", + "name", datatransfer.Events[event.Code], + "status", datatransfer.Statuses[state.Status()], + "transfer ID", state.TransferID(), + "channel ID", state.ChannelID(), + "sent", state.Sent(), + "received", state.Received(), + "queued", state.Queued(), + "received count", len(state.ReceivedCids()), + "total size", state.TotalSize(), + "remote peer", state.OtherPeer(), + "event message", event.Message, + "channel message", state.Message()) +} + // ReadyLogger returns a function to log the results of module initialization func ReadyLogger(module string) func(error) { return func(err error) { diff --git a/node/modules/client.go b/node/modules/client.go index 67eaffe886..18bba2417c 100644 --- a/node/modules/client.go +++ b/node/modules/client.go @@ -137,6 +137,7 @@ func NewClientGraphsyncDataTransfer(lc fx.Lifecycle, h host.Host, gs dtypes.Grap dt.OnReady(marketevents.ReadyLogger("client data transfer")) lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { + dt.SubscribeToEvents(marketevents.DataTransferLogger) return dt.Start(ctx) }, OnStop: func(ctx context.Context) error {