diff --git a/internal/utils/singleton.go b/internal/utils/singleton.go index fa2ffc9c8..55e44193e 100644 --- a/internal/utils/singleton.go +++ b/internal/utils/singleton.go @@ -5,6 +5,8 @@ package utils import ( "sync" "sync/atomic" + + "github.com/harmony-one/harmony/log" ) // UniqueValidatorID defines the structure of unique validator ID @@ -13,7 +15,9 @@ type UniqueValidatorID struct { } var instance *UniqueValidatorID +var logInstance log.Logger var once sync.Once +var onceForLog sync.Once // GetUniqueValidatorIDInstance returns a singleton instance func GetUniqueValidatorIDInstance() *UniqueValidatorID { @@ -29,3 +33,10 @@ func GetUniqueValidatorIDInstance() *UniqueValidatorID { func (s *UniqueValidatorID) GetUniqueID() uint32 { return atomic.AddUint32(&s.uniqueID, 1) } + +func GetLogInstance() log.Logger { + onceForLog.Do(func() { + logInstance = log.New() + }) + return logInstance +}