diff --git a/cmd/downloader/downloader/torrentcfg/logger.go b/cmd/downloader/downloader/torrentcfg/logger.go index cbd477d30ea5df5b1c15b1688c419a3631c54a73..681a24339a86f03c020421b08d23fbf596cc5af1 100644 --- a/cmd/downloader/downloader/torrentcfg/logger.go +++ b/cmd/downloader/downloader/torrentcfg/logger.go @@ -1,23 +1,22 @@ package torrentcfg import ( - stdlog "log" - "strings" - - utp "github.com/anacrolix/go-libutp" lg "github.com/anacrolix/log" - "github.com/ledgerwatch/log/v3" ) func init() { lg.Default = NewAdapterLogger() - utp.Logger = stdlog.New(NullWriter(1), "", stdlog.LstdFlags) + //a := stdlog.New(NullWriter(1), "", stdlog.LstdFlags) + //var Logger = log.Default.WithContextText("go-libutp") + //utp.Logger = a } func NewAdapterLogger() lg.Logger { - return lg.Logger{ - LoggerImpl: lg.LoggerImpl(adapterLogger{}), - } + return lg.Default + //lg.Logger{Handlers:} + //return lg.Logger{ + // LoggerImpl: lg.LoggerImpl(adapterLogger{}), + //} } var String2LogLevel = map[string]lg.Level{ @@ -30,50 +29,52 @@ var String2LogLevel = map[string]lg.Level{ type adapterLogger struct{} func (b adapterLogger) 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: - str := msg.String() - if strings.Contains(str, "EOF") || - strings.Contains(str, "spurious timer") || - strings.Contains(str, "banning ip <nil>") { // suppress useless errors - break + /* + lvl, ok := msg.GetLevel() + if !ok { + lvl = lg.Debug } - log.Info(str) - case lg.Warning: - str := msg.String() - if strings.Contains(str, "could not find offer for id") { // suppress useless errors - break - } + switch lvl { + case lg.Debug: + log.Debug(msg.String()) + case lg.Info: + str := msg.String() + if strings.Contains(str, "EOF") || + strings.Contains(str, "spurious timer") || + strings.Contains(str, "banning ip <nil>") { // suppress useless errors + break + } - log.Warn(str) - case lg.Error: - str := msg.String() - if strings.Contains(str, "EOF") { // suppress useless errors - break - } + log.Info(str) + case lg.Warning: + str := msg.String() + if strings.Contains(str, "could not find offer for id") { // suppress useless errors + break + } - log.Error(str) - case lg.Critical: - str := msg.String() - if strings.Contains(str, "EOF") { // suppress useless errors - break - } - if strings.Contains(str, "don't want conns") { // suppress useless errors - break - } + log.Warn(str) + case lg.Error: + str := msg.String() + if strings.Contains(str, "EOF") { // suppress useless errors + break + } - log.Error(str) - default: - log.Warn("unknown log type", "msg", msg.String()) - } + log.Error(str) + case lg.Critical: + str := msg.String() + if strings.Contains(str, "EOF") { // suppress useless errors + break + } + if strings.Contains(str, "don't want conns") { // suppress useless errors + break + } + + log.Error(str) + default: + log.Warn("unknown logtype", "msg", msg.String()) + } + */ } // NullWriter implements the io.Write interface but doesn't do anything.