tstor/log/torrent.go

33 lines
545 B
Go
Raw Normal View History

package log
import (
"github.com/anacrolix/log"
"github.com/rs/zerolog"
)
2023-09-05 15:05:27 +00:00
var _ log.Handler = &Torrent{}
type Torrent struct {
L zerolog.Logger
}
2023-09-05 15:05:27 +00:00
func (l *Torrent) Handle(r log.Record) {
e := l.L.Info()
2023-09-05 15:05:27 +00:00
switch r.Level {
case log.Debug:
e = l.L.Debug()
case log.Info:
e = l.L.Debug().Str("error-type", "info")
case log.Warning:
e = l.L.Warn()
case log.Error:
e = l.L.Warn().Str("error-type", "error")
case log.Critical:
e = l.L.Warn().Str("error-type", "critical")
}
2023-09-05 15:05:27 +00:00
// TODO set log values somehow
e.Msgf(r.Text())
}