44 lines
978 B
Go
Raw Normal View History

package waku
import (
"sync"
"github.com/sirupsen/logrus"
)
var (
once sync.Once
instance *logrus.Logger
)
2025-02-11 16:21:14 +02:00
// _getLogger ensures we always return the same logger instance (private function)
func _getLogger() *logrus.Logger {
once.Do(func() {
instance = logrus.New()
instance.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
instance.SetLevel(logrus.DebugLevel) // Set default log level
})
return instance
}
// Debug logs a debug message
func Debug(msg string, args ...interface{}) {
2025-02-11 16:21:14 +02:00
_getLogger().WithFields(logrus.Fields{}).Debugf(msg, args...)
}
// Info logs an info message
func Info(msg string, args ...interface{}) {
2025-02-11 16:21:14 +02:00
_getLogger().WithFields(logrus.Fields{}).Infof(msg, args...)
}
// Error logs an error message
func Error(msg string, args ...interface{}) {
2025-02-11 16:21:14 +02:00
_getLogger().WithFields(logrus.Fields{}).Errorf(msg, args...)
}
func Warn(msg string, args ...interface{}) {
_getLogger().WithFields(logrus.Fields{}).Warnf(msg, args...)
}