Skip to content

Commit

Permalink
v2: consistent logs
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerinthenight committed Jul 16, 2024
1 parent 50c9ae6 commit 307c9c8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spindle.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (l *Lock) Run(ctx context.Context, done ...chan error) error {
// Attempt first ever lock. The return commit timestamp will be our fencing
// token. Only one node should be able to do this successfully.
if initial.Load() == 1 {
prefix := "[init]"
prefix := "init:"
cts, err := l.db.ReadWriteTransaction(context.Background(),
func(ctx context.Context, txn *spanner.ReadWriteTransaction) error {
var q strings.Builder
Expand All @@ -170,7 +170,7 @@ func (l *Lock) Run(ctx context.Context, done ...chan error) error {

if err == nil {
l.setToken(&cts)
l.logger.Printf("%v got the lock with token [%v]", prefix, l.token())
l.logger.Printf("%v got the lock with token %v", prefix, l.token())
return
}

Expand All @@ -179,7 +179,7 @@ func (l *Lock) Run(ctx context.Context, done ...chan error) error {

// For the succeeding lock attempts.
if initial.Load() == 0 {
prefix := "[next]"
prefix := "next:"
token, _, err := l.getCurrentToken()
if err != nil {
l.logger.Printf("%v getCurrentToken failed: %v", prefix, err)
Expand Down Expand Up @@ -234,7 +234,7 @@ func (l *Lock) Run(ctx context.Context, done ...chan error) error {
}

l.setToken(&nts) // doesn't mean we're leader
l.logger.Printf("%v got the lock: token=%v", prefix, l.token())
l.logger.Printf("%v got the lock with token %v", prefix, l.token())
}
}
}
Expand Down

0 comments on commit 307c9c8

Please sign in to comment.