Skip to content

Commit

Permalink
Use trace log level for heartbeat and debug for other messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Oct 29, 2024
1 parent 776c8b8 commit 9d9b7dd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ func (mcs *mcs) disconnect() {
})
}

func (mcs *mcs) getLogEventForTag(tag tagType) *zerolog.Event {
if tag == tagHeartbeatPing || tag == tagHeartbeatAck {
return mcs.log.Trace()
} else {
return mcs.log.Debug()
}
}

func (mcs *mcs) SendLoginPacket(receivedPersistentId []string) error {
androidID := proto.String(strconv.FormatUint(mcs.creds.AndroidID, 10))

Expand Down Expand Up @@ -131,8 +139,8 @@ func (mcs *mcs) sendRequest(tag tagType, request proto.Message, containVersion b
header = append(header, byte(tag))
}

mcs.log.Trace().
Str("tag_type", string(tag)).
mcs.getLogEventForTag(tag).
Str("tag", string(tag)).
Any("request", request).
Msg("Send MCS request")

Expand Down Expand Up @@ -201,7 +209,7 @@ func (mcs *mcs) UnmarshalTagData(tag tagType, buf []byte) (any, error) {
return receive, errors.Wrapf(err, "unmarshal tag(%x) data", tag)
}

mcs.log.Trace().
mcs.getLogEventForTag(tag).
Str("tag", string(tag)).
Any("receive", receive).
Msg("Receive MCS message")
Expand Down

0 comments on commit 9d9b7dd

Please sign in to comment.