Merge pull request #4975 from filecoin-project/feat/data-transfer-logging
add data transfer logging
This commit is contained in:
commit
7e2d05cfd7
@ -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) {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user