2020-11-13 16:16:47 +00:00
|
|
|
package bittorrent
|
2020-10-13 12:56:16 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
lg "github.com/anacrolix/log"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2020-11-13 16:16:47 +00:00
|
|
|
lg.Default = NewAdapterLogger()
|
2020-10-13 12:56:16 +00:00
|
|
|
}
|
2020-11-13 16:16:47 +00:00
|
|
|
func NewAdapterLogger() lg.Logger {
|
2020-10-13 12:56:16 +00:00
|
|
|
return lg.Logger{
|
2020-11-13 16:16:47 +00:00
|
|
|
lg.LoggerImpl(adapterLogger{}),
|
2020-10-13 12:56:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-13 16:16:47 +00:00
|
|
|
type adapterLogger struct{}
|
2020-10-13 12:56:16 +00:00
|
|
|
|
2020-11-13 16:16:47 +00:00
|
|
|
func (b adapterLogger) Log(msg lg.Msg) {
|
2020-10-13 12:56:16 +00:00
|
|
|
lvl, ok := msg.GetLevel()
|
|
|
|
if !ok {
|
2020-11-13 16:16:47 +00:00
|
|
|
lvl = lg.Info
|
2020-10-13 12:56:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch lvl {
|
|
|
|
case lg.Debug:
|
|
|
|
log.Debug(msg.String())
|
|
|
|
case lg.Info:
|
|
|
|
log.Info(msg.String())
|
|
|
|
case lg.Warning:
|
|
|
|
log.Warn(msg.String())
|
|
|
|
case lg.Error:
|
|
|
|
log.Error(msg.String())
|
|
|
|
case lg.Critical:
|
|
|
|
log.Error(msg.String())
|
|
|
|
default:
|
2020-11-13 16:16:47 +00:00
|
|
|
log.Warn("unknown log type", "msg", msg.String())
|
2020-10-13 12:56:16 +00:00
|
|
|
}
|
|
|
|
}
|