2019-07-17 22:25:42 +00:00
|
|
|
package logutils
|
|
|
|
|
|
|
|
import (
|
2020-02-18 11:21:01 +00:00
|
|
|
"sync"
|
|
|
|
|
|
|
|
"go.uber.org/zap"
|
|
|
|
|
2019-07-17 22:25:42 +00:00
|
|
|
"github.com/ethereum/go-ethereum/log"
|
|
|
|
)
|
|
|
|
|
2020-02-18 11:21:01 +00:00
|
|
|
var (
|
|
|
|
_zapLogger *zap.Logger
|
|
|
|
_initZapLogger sync.Once
|
|
|
|
)
|
|
|
|
|
|
|
|
// ZapLogger creates a custom zap.Logger which will forward logs
|
|
|
|
// to status-go logger.
|
|
|
|
func ZapLogger() *zap.Logger {
|
|
|
|
_initZapLogger.Do(func() {
|
|
|
|
var err error
|
2023-11-09 06:35:59 +00:00
|
|
|
_zapLogger, err = NewZapLoggerWithAdapter(log.Root())
|
2020-02-18 11:21:01 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return _zapLogger
|
|
|
|
}
|