erigon-pulse/turbo/torrent/logger.go
b00ris 4ebade3583
Add sync by bittorrent snapshots (#1160)
* save state

* torrent experiments

* torrent experiment passed

* fixes after merge

* snapshot headers processing passed

* save state

* save state

* download headers works after snapshot processing

* save state

* save state

* save state

* save state

* add lazy load tx to snapshots, increase number of trackers

* save state

* speedup getting info

* change logging

* move to turbo package

* save state

* save state

* save state

* cleanup

* save state

* add test test

* save state

* lmdb debugging

* fix readonly mode

* save state

* fix build

* sync works

* save state

* save state

* save state

* allow cmd stages stageSenders use snapshots

* debugging failed hashing

* remove experimental tests

* remove torrent experimental tests

* fix lint

* extract snapshot wrapper

* metainfo checker

* add remote seeder

* add logs

* update gomod

* remove useless code

* fix lint&remove useless code

* extract verify snapshot to separated command

* skip debug test

* fix test

* change type of seedSnapshot flag

* add eth logger to torrent lib

* skip debug test

* add Close method

* review fixes

* fix lint

Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
Co-authored-by: Alexey Akhunov <akhounov@gmail.com>
2020-10-06 20:24:48 +01:00

41 lines
641 B
Go

package torrent
import (
lg "github.com/anacrolix/log"
"github.com/ledgerwatch/turbo-geth/log"
)
func init() {
lg.Default = NewLogger()
}
func NewLogger() lg.Logger {
return lg.Logger{
lg.LoggerImpl(btLogger{}),
}
}
type btLogger struct{}
func (b btLogger) Log(msg lg.Msg) {
lvl, ok := msg.GetLevel()
if !ok {
lvl = lg.Debug
}
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:
log.Warn("unknown log type")
log.Warn(msg.String())
}
}