From 50ca5322f53ed5b6b763992b3196936a8adb88a0 Mon Sep 17 00:00:00 2001 From: "U. Cirello" Date: Tue, 26 Sep 2023 09:12:36 -0700 Subject: [PATCH] pglock: fix logs --- client.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client.go b/client.go index deb2f1a..b563665 100644 --- a/client.go +++ b/client.go @@ -188,7 +188,7 @@ func (c *Client) AcquireContext(ctx context.Context, name string, opts ...LockOp c.log.Debug("not acquired, exit") return l, err } else if err == ErrNotAcquired { - c.log.Debug("not acquired, wait:", l.leaseDuration) + c.log.Debug("not acquired, wait: %v", l.leaseDuration) select { case <-time.After(l.leaseDuration): case <-ctx.Done(): @@ -196,7 +196,7 @@ func (c *Client) AcquireContext(ctx context.Context, name string, opts ...LockOp } continue } else if err != nil { - c.log.Error("error:", err) + c.log.Error("error: %v", err) return nil, err } return l, nil @@ -232,9 +232,9 @@ func (c *Client) storeAcquire(ctx context.Context, l *Lock) error { if err != nil { return typedError(err, "cannot create transaction for lock acquisition") } - c.log.Debug("storeAcquire in", l.name, rvn, l.data, l.recordVersionNumber) + c.log.Debug("storeAcquire in: %v %v %v %v", l.name, rvn, l.data, l.recordVersionNumber) defer func() { - c.log.Debug("storeAcquire out", l.name, rvn, l.data, l.recordVersionNumber) + c.log.Debug("storeAcquire out: %v %v %v %v", l.name, rvn, l.data, l.recordVersionNumber) }() _, err = tx.ExecContext(ctx, ` INSERT INTO `+c.tableName+` @@ -361,13 +361,13 @@ func (c *Client) storeRelease(ctx context.Context, l *Lock) error { func (c *Client) heartbeat(ctx context.Context, l *Lock) { defer l.heartbeatWG.Done() - c.log.Debug("heartbeat started", l.name) - defer c.log.Debug("heartbeat stopped", l.name) + c.log.Debug("heartbeat started: %v", l.name) + defer c.log.Debug("heartbeat stopped: %v", l.name) for { if err := ctx.Err(); err != nil { return } else if err := c.SendHeartbeat(ctx, l); err != nil { - defer c.log.Error("heartbeat missed", err) + defer c.log.Error("heartbeat missed: %v", err) return } select { @@ -459,7 +459,7 @@ func (c *Client) GetContext(ctx context.Context, name string) (*Lock, error) { return err }) if notExist := (&NotExistError{}); err != nil && errors.As(err, ¬Exist) { - c.log.Error("missing lock entry:", err) + c.log.Error("missing lock entry: %v", err) } return l, err } @@ -506,7 +506,7 @@ func (c *Client) retry(ctx context.Context, f func() error) error { if failedPrecondition := (&FailedPreconditionError{}); err == nil || !errors.As(err, &failedPrecondition) { break } - c.log.Debug("bad transaction, retrying:", err) + c.log.Debug("bad transaction, retrying: %v", err) select { case <-time.After(retryPeriod): case <-ctx.Done():