github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/p2p/utils/logger.go (about)

     1  package utils
     2  
     3  import (
     4  	pubsub "github.com/libp2p/go-libp2p-pubsub"
     5  	"github.com/rs/zerolog"
     6  )
     7  
     8  // TopicScoreParamsLogger is a helper function that returns a logger with the topic score params added as fields.
     9  // Args:
    10  // logger: zerolog.Logger - logger to add fields to
    11  // topicName: string - name of the topic
    12  // params: pubsub.TopicScoreParams - topic score params
    13  func TopicScoreParamsLogger(logger zerolog.Logger, topicName string, topicParams *pubsub.TopicScoreParams) zerolog.Logger {
    14  	return logger.With().Str("topic", topicName).
    15  		Bool("atomic_validation", topicParams.SkipAtomicValidation).
    16  		Float64("topic_weight", topicParams.TopicWeight).
    17  		Float64("time_in_mesh_weight", topicParams.TimeInMeshWeight).
    18  		Dur("time_in_mesh_quantum", topicParams.TimeInMeshQuantum).
    19  		Float64("time_in_mesh_cap", topicParams.TimeInMeshCap).
    20  		Float64("first_message_deliveries_weight", topicParams.FirstMessageDeliveriesWeight).
    21  		Float64("first_message_deliveries_decay", topicParams.FirstMessageDeliveriesDecay).
    22  		Float64("first_message_deliveries_cap", topicParams.FirstMessageDeliveriesCap).
    23  		Float64("mesh_message_deliveries_weight", topicParams.MeshMessageDeliveriesWeight).
    24  		Float64("mesh_message_deliveries_decay", topicParams.MeshMessageDeliveriesDecay).
    25  		Float64("mesh_message_deliveries_cap", topicParams.MeshMessageDeliveriesCap).
    26  		Float64("mesh_message_deliveries_threshold", topicParams.MeshMessageDeliveriesThreshold).
    27  		Dur("mesh_message_deliveries_window", topicParams.MeshMessageDeliveriesWindow).
    28  		Dur("mesh_message_deliveries_activation", topicParams.MeshMessageDeliveriesActivation).
    29  		Float64("mesh_failure_penalty_weight", topicParams.MeshFailurePenaltyWeight).
    30  		Float64("mesh_failure_penalty_decay", topicParams.MeshFailurePenaltyDecay).
    31  		Float64("invalid_message_deliveries_weight", topicParams.InvalidMessageDeliveriesWeight).
    32  		Float64("invalid_message_deliveries_decay", topicParams.InvalidMessageDeliveriesDecay).Logger()
    33  }