gotd: reduce unnecessary debug logs
This commit is contained in:
@@ -10,8 +10,6 @@ import (
|
||||
)
|
||||
|
||||
func (c *Conn) ackLoop(ctx context.Context) error {
|
||||
log := c.log.Named("ack")
|
||||
|
||||
var buf []int64
|
||||
send := func() {
|
||||
defer func() { buf = buf[:0] }()
|
||||
@@ -20,8 +18,6 @@ func (c *Conn) ackLoop(ctx context.Context) error {
|
||||
c.log.Error("Failed to ACK", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug("Ack", zap.Int64s("msg_ids", buf))
|
||||
}
|
||||
|
||||
ticker := c.clock.Ticker(c.ackInterval)
|
||||
|
||||
@@ -2,7 +2,6 @@ package mtproto
|
||||
|
||||
import (
|
||||
"github.com/go-faster/errors"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/mt"
|
||||
@@ -14,7 +13,6 @@ func (c *Conn) handleAck(b *bin.Buffer) error {
|
||||
return errors.Wrap(err, "decode")
|
||||
}
|
||||
|
||||
c.log.Debug("Received ack", zap.Int64s("msg_ids", ack.MsgIDs))
|
||||
c.rpc.NotifyAcks(ack.MsgIDs)
|
||||
|
||||
return nil
|
||||
|
||||
@@ -2,7 +2,6 @@ package mtproto
|
||||
|
||||
import (
|
||||
"github.com/go-faster/errors"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/mt"
|
||||
@@ -16,8 +15,6 @@ func (c *Conn) handleMessage(msgID int64, b *bin.Buffer) error {
|
||||
return errors.Wrap(err, "peek message type")
|
||||
}
|
||||
|
||||
c.logWithBuffer(b).Debug("Handle message", zap.Int64("msg_id", msgID))
|
||||
|
||||
switch id {
|
||||
case mt.NewSessionCreatedTypeID:
|
||||
return c.handleSessionCreated(b)
|
||||
|
||||
@@ -21,7 +21,6 @@ func (c *Conn) handleResult(b *bin.Buffer) error {
|
||||
b.ResetTo(res.Result)
|
||||
|
||||
msgID := zap.Int64("msg_id", res.RequestMessageID)
|
||||
c.logWithBuffer(b).Debug("Handle result", msgID)
|
||||
|
||||
// Handling gzipped results.
|
||||
id, err := b.PeekID()
|
||||
@@ -36,7 +35,6 @@ func (c *Conn) handleResult(b *bin.Buffer) error {
|
||||
|
||||
// Replacing buffer so callback will deal with uncompressed data.
|
||||
b = content
|
||||
c.logWithBuffer(b).Debug("Decompressed", msgID)
|
||||
|
||||
// Replacing id with inner id if error is compressed for any reason.
|
||||
if id, err = b.PeekID(); err != nil {
|
||||
|
||||
@@ -2,7 +2,6 @@ package mtproto
|
||||
|
||||
import (
|
||||
"github.com/go-faster/errors"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/crypto"
|
||||
@@ -16,14 +15,8 @@ func (c *Conn) newEncryptedMessage(id int64, seq int32, payload bin.Encoder, b *
|
||||
// 1) Generate Length() method for every encoder, to count length without encoding.
|
||||
// 2) Re-use buffer instead of using yet one.
|
||||
// 3) Do not send proto.GZIP if gzipped size is equal or bigger.
|
||||
var (
|
||||
d crypto.EncryptedMessageData
|
||||
log = c.log
|
||||
)
|
||||
var d crypto.EncryptedMessageData
|
||||
if c.compressThreshold <= 0 {
|
||||
if obj, ok := payload.(interface{ TypeID() uint32 }); ok {
|
||||
log = c.logWithTypeID(obj.TypeID())
|
||||
}
|
||||
d = crypto.EncryptedMessageData{
|
||||
SessionID: s.ID,
|
||||
Salt: s.Salt,
|
||||
@@ -38,7 +31,6 @@ func (c *Conn) newEncryptedMessage(id int64, seq int32, payload bin.Encoder, b *
|
||||
return errors.Wrap(err, "encode payload")
|
||||
}
|
||||
|
||||
log = c.logWithType(payloadBuf)
|
||||
if payloadBuf.Len() > c.compressThreshold {
|
||||
d = crypto.EncryptedMessageData{
|
||||
SessionID: s.ID,
|
||||
@@ -59,7 +51,6 @@ func (c *Conn) newEncryptedMessage(id int64, seq int32, payload bin.Encoder, b *
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug("Request", zap.Int64("msg_id", id))
|
||||
if err := c.cipher.Encrypt(s.Key, d, b); err != nil {
|
||||
return errors.Wrap(err, "encrypt")
|
||||
}
|
||||
|
||||
@@ -23,22 +23,14 @@ func (c *Conn) Invoke(ctx context.Context, input bin.Encoder, output bin.Decoder
|
||||
Output: output,
|
||||
}
|
||||
|
||||
log := c.log.With(
|
||||
zap.Int64("msg_id", req.MsgID),
|
||||
)
|
||||
log.Debug("Invoke start")
|
||||
defer log.Debug("Invoke end")
|
||||
|
||||
if err := c.rpc.Do(ctx, req); err != nil {
|
||||
var badMsgErr *badMessageError
|
||||
if errors.As(err, &badMsgErr) && badMsgErr.Code == codeIncorrectServerSalt {
|
||||
// Should retry with new salt.
|
||||
c.log.Debug("Setting server salt")
|
||||
// Store salt from server.
|
||||
c.storeSalt(badMsgErr.NewSalt)
|
||||
// Reset saved salts to fetch new.
|
||||
c.salts.Reset()
|
||||
c.log.Info("Retrying request after basMsgErr", zap.Int64("msg_id", req.MsgID))
|
||||
c.log.Info("Retrying request after updating salt from badMsgErr", zap.Int64("msg_id", req.MsgID))
|
||||
return c.rpc.Do(ctx, req)
|
||||
}
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user