Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

adjust logs

chrislu766985224199
diff --git a/weed/util/lock_table.go b/weed/util/lock_table.go
index 32d98bea31..015e424f9a 100644
--- a/weed/util/lock_table.go
+++ b/weed/util/lock_table.go
@@ -2,6 +2,7 @@ package util
import (
"fmt"
+ "github.com/seaweedfs/seaweedfs/weed/glog"
"sync"
"sync/atomic"
)
@@ -63,7 +64,7 @@ func (lt *LockTable[T]) AcquireLock(intention string, key T, lockType LockType)
// If the lock is held exclusively, wait
entry.mu.Lock()
if len(entry.waiters) > 0 || lockType == ExclusiveLock {
- fmt.Printf("ActiveLock %d %s wait for %+v type=%v with waiters %d active %d.\n", lock.ID, lock.intention, key, lockType, len(entry.waiters), entry.activeLockOwnerCount)
+ glog.V(4).Infof("ActiveLock %d %s wait for %+v type=%v with waiters %d active %d.\n", lock.ID, lock.intention, key, lockType, len(entry.waiters), entry.activeLockOwnerCount)
if len(entry.waiters) > 0 {
for _, waiter := range entry.waiters {
fmt.Printf(" %d", waiter.ID)
@@ -90,7 +91,7 @@ func (lt *LockTable[T]) AcquireLock(intention string, key T, lockType LockType)
// Otherwise, grant the lock
entry.lockType = lockType
- fmt.Printf("ActiveLock %d %s locked %+v type=%v with waiters %d active %d.\n", lock.ID, lock.intention, key, lockType, len(entry.waiters), entry.activeLockOwnerCount)
+ glog.V(4).Infof("ActiveLock %d %s locked %+v type=%v with waiters %d active %d.\n", lock.ID, lock.intention, key, lockType, len(entry.waiters), entry.activeLockOwnerCount)
if len(entry.waiters) > 0 {
for _, waiter := range entry.waiters {
fmt.Printf(" %d", waiter.ID)
@@ -128,7 +129,7 @@ func (lt *LockTable[T]) ReleaseLock(key T, lock *ActiveLock) {
delete(lt.locks, key)
}
- fmt.Printf("ActiveLock %d %s unlocked %+v type=%v with waiters %d active %d.\n", lock.ID, lock.intention, key, entry.lockType, len(entry.waiters), entry.activeLockOwnerCount)
+ glog.V(4).Infof("ActiveLock %d %s unlocked %+v type=%v with waiters %d active %d.\n", lock.ID, lock.intention, key, entry.lockType, len(entry.waiters), entry.activeLockOwnerCount)
if len(entry.waiters) > 0 {
for _, waiter := range entry.waiters {
fmt.Printf(" %d", waiter.ID)
diff --git a/weed/util/lock_table_test.go b/weed/util/lock_table_test.go
index f9037559c2..272e5672fe 100644
--- a/weed/util/lock_table_test.go
+++ b/weed/util/lock_table_test.go
@@ -1,7 +1,6 @@
package util
import (
- "fmt"
"math/rand"
"sync"
"testing"
@@ -27,14 +26,14 @@ func TestOrderedLock(t *testing.T) {
lock := lt.AcquireLock("", key, lockType)
// Lock acquired, perform some work
- fmt.Printf("ActiveLock %d acquired the lock.\n", lock.ID)
+ glog.V(4).Infof("ActiveLock %d acquired the lock.\n", lock.ID)
// Simulate some work
time.Sleep(time.Duration(rand.Int31n(10)*10) * time.Millisecond)
// Release the lock
lt.ReleaseLock(key, lock)
- fmt.Printf("ActiveLock %d released the lock.\n", lock.ID)
+ glog.V(4).Infof("ActiveLock %d released the lock.\n", lock.ID)
}(i)
}