Skip to content

Commit

Permalink
Add logger to logical decoding singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyhb committed Oct 8, 2024
1 parent fbe5747 commit cd89c86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pkg/decoder/pg_logical_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)

func NewV1LogicalDecoder(s *schema.PGXSchemaLoader) Decoder {
func NewV1LogicalDecoder(s *schema.PGXSchemaLoader, log *slog.Logger) Decoder {
return v1LogicalDecoder{
log: log,
schema: s,
relations: make(map[uint32]*pglogrepl.RelationMessage),
}
Expand Down Expand Up @@ -81,7 +82,9 @@ func (v v1LogicalDecoder) Decode(in []byte, cs *changeset.Changeset) (bool, erro

default:
// Unsupported message - log and carry on.
v.log.Debug("unsupported message type in v1 decoder", "msg_type", msgType.String())
if v.log != nil {
v.log.Debug("unsupported message type in v1 decoder", "msg_type", msgType)
}
}

return false, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/replicator/pgreplicator/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func New(ctx context.Context, opts Opts) (PostgresReplicator, error) {
opts: opts,
conn: replConn,
queryConn: pgxc,
decoder: decoder.NewV1LogicalDecoder(sl),
decoder: decoder.NewV1LogicalDecoder(sl, opts.Log),
log: opts.Log,
}, nil
}
Expand Down

0 comments on commit cd89c86

Please sign in to comment.