Move from logrus to zerolog. (#45)

Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
This commit is contained in:
Antonio Navarro Perez 2021-03-10 10:54:56 +01:00 committed by GitHub
parent 2a38efbb03
commit 3b87e4aad7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 50 additions and 39 deletions

View file

@ -4,8 +4,8 @@ package main
import ( import (
"github.com/distribyted/distribyted" "github.com/distribyted/distribyted"
"github.com/rs/zerolog/log"
"github.com/shurcooL/vfsgen" "github.com/shurcooL/vfsgen"
log "github.com/sirupsen/logrus"
) )
func main() { func main() {
@ -15,6 +15,6 @@ func main() {
PackageName: "distribyted", PackageName: "distribyted",
}) })
if err != nil { if err != nil {
log.Fatalln(err) log.Fatal().Err(err).Msg("problem generating static files")
} }
} }

View file

@ -15,10 +15,17 @@ import (
"github.com/distribyted/distribyted/stats" "github.com/distribyted/distribyted/stats"
"github.com/distribyted/distribyted/torrent" "github.com/distribyted/distribyted/torrent"
"github.com/distribyted/distribyted/webdav" "github.com/distribyted/distribyted/webdav"
"github.com/sirupsen/logrus" "github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
func init() {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
zerolog.SetGlobalLevel(zerolog.InfoLevel)
}
const ( const (
configFlag = "config" configFlag = "config"
fuseAllowOther = "fuse-allow-other" fuseAllowOther = "fuse-allow-other"
@ -66,7 +73,7 @@ func main() {
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
logrus.Fatal(err) log.Fatal().Err(err).Msg("problem starting application")
} }
} }
@ -144,28 +151,28 @@ func load(configPath string, port, webDAVPort int, fuseAllowOther bool) error {
if conf.WebDAV != nil { if conf.WebDAV != nil {
wdth := torrent.NewHandler(c, ss) wdth := torrent.NewHandler(c, ss)
if err := wdth.Load("::/webDAV", conf.WebDAV.Torrents); err != nil { if err := wdth.Load("::/webDAV", conf.WebDAV.Torrents); err != nil {
logrus.WithError(err).Error("error loading torrents for webDAV") log.Error().Err(err).Msg("error loading torrents for webDAV")
} }
if err := webdav.NewWebDAVServer(wdth.Fileststems(), webDAVPort); err != nil { if err := webdav.NewWebDAVServer(wdth.Fileststems(), webDAVPort); err != nil {
logrus.WithError(err).Error("error starting webDAV") log.Error().Err(err).Msg("error starting webDAV")
} }
} }
}() }()
err = http.New(fc, ss, ch, port) err = http.New(fc, ss, ch, port)
logrus.WithError(err).Error("error initializing HTTP server") log.Error().Err(err).Msg("error initializing HTTP server")
return err return err
} }
func tryClose(c *t.Client, mountService *fuse.Handler) { func tryClose(c *t.Client, mountService *fuse.Handler) {
logrus.Info("closing torrent client...") log.Info().Msg("closing torrent client...")
c.Close() c.Close()
logrus.Info("unmounting fuse filesystem...") log.Info().Msg("unmounting fuse filesystem...")
mountService.UnmountAll() mountService.UnmountAll()
logrus.Info("exiting") log.Info().Msg("exiting")
os.Exit(1) os.Exit(1)
} }

View file

@ -7,7 +7,7 @@ import (
"path" "path"
"github.com/distribyted/distribyted" "github.com/distribyted/distribyted"
"github.com/sirupsen/logrus" "github.com/rs/zerolog/log"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )
@ -44,7 +44,7 @@ func (c *Handler) createFromTemplateFile() ([]byte, error) {
func (c *Handler) GetRaw() ([]byte, error) { func (c *Handler) GetRaw() ([]byte, error) {
f, err := ioutil.ReadFile(c.p) f, err := ioutil.ReadFile(c.p)
if os.IsNotExist(err) { if os.IsNotExist(err) {
logrus.WithField("file", c.p).Info("configuration file does not exist, creating from template file") log.Info().Str("file", c.p).Msg("configuration file does not exist, creating from template file")
return c.createFromTemplateFile() return c.createFromTemplateFile()
} }

View file

@ -8,7 +8,7 @@ import (
"github.com/billziss-gh/cgofuse/fuse" "github.com/billziss-gh/cgofuse/fuse"
"github.com/distribyted/distribyted/config" "github.com/distribyted/distribyted/config"
"github.com/distribyted/distribyted/fs" "github.com/distribyted/distribyted/fs"
log "github.com/sirupsen/logrus" "github.com/rs/zerolog/log"
) )
type Handler struct { type Handler struct {
@ -47,7 +47,7 @@ func (s *Handler) MountAll(fss map[string]fs.Filesystem, ef config.EventFunc) er
ok := host.Mount(p, config) ok := host.Mount(p, config)
if !ok { if !ok {
log.WithField("path", p).Error("error trying to mount filesystem") log.Error().Str("path", p).Msg("error trying to mount filesystem")
} }
}() }()
@ -59,11 +59,11 @@ func (s *Handler) MountAll(fss map[string]fs.Filesystem, ef config.EventFunc) er
func (s *Handler) UnmountAll() { func (s *Handler) UnmountAll() {
for path, server := range s.hosts { for path, server := range s.hosts {
log.WithField("path", path).Info("unmounting") log.Info().Str("path", path).Msg("unmounting")
ok := server.Unmount() ok := server.Unmount()
if !ok { if !ok {
//TODO try to force unmount if possible //TODO try to force unmount if possible
log.WithField("path", path).Error("unmount failed") log.Error().Str("path", path).Msg("unmount failed")
} }
} }

View file

@ -9,7 +9,7 @@ import (
"github.com/billziss-gh/cgofuse/fuse" "github.com/billziss-gh/cgofuse/fuse"
"github.com/distribyted/distribyted/fs" "github.com/distribyted/distribyted/fs"
"github.com/sirupsen/logrus" "github.com/rs/zerolog/log"
) )
type FS struct { type FS struct {
@ -26,12 +26,12 @@ func NewFS(fs fs.Filesystem) fuse.FileSystemInterface {
func (fs *FS) Open(path string, flags int) (errc int, fh uint64) { func (fs *FS) Open(path string, flags int) (errc int, fh uint64) {
fh, err := fs.fh.OpenHolder(path) fh, err := fs.fh.OpenHolder(path)
if err == os.ErrNotExist { if err == os.ErrNotExist {
logrus.WithField("path", path).Debug("file does not exists") log.Debug().Str("path", path).Msg("file does not exists")
return -fuse.ENOENT, fhNone return -fuse.ENOENT, fhNone
} }
if err != nil { if err != nil {
logrus.WithError(err).WithField("path", path).Error("error opening file") log.Error().Err(err).Str("path", path).Msg("error opening file")
return -fuse.EIO, fhNone return -fuse.EIO, fhNone
} }
@ -50,12 +50,12 @@ func (cfs *FS) Getattr(path string, stat *fuse.Stat_t, fh uint64) (errc int) {
file, err := cfs.fh.GetFile(path, fh) file, err := cfs.fh.GetFile(path, fh)
if err == os.ErrNotExist { if err == os.ErrNotExist {
logrus.WithField("path", path).Debug("file does not exists") log.Debug().Str("path", path).Msg("file does not exists")
return -fuse.ENOENT return -fuse.ENOENT
} }
if err != nil { if err != nil {
logrus.WithError(err).WithField("path", path).Error("error getting holder when reading file attributes") log.Error().Err(err).Str("path", path).Msg("error getting holder when reading file attributes")
return -fuse.EIO return -fuse.EIO
} }
@ -72,12 +72,12 @@ func (cfs *FS) Getattr(path string, stat *fuse.Stat_t, fh uint64) (errc int) {
func (fs *FS) Read(path string, dest []byte, off int64, fh uint64) int { func (fs *FS) Read(path string, dest []byte, off int64, fh uint64) int {
file, err := fs.fh.GetFile(path, fh) file, err := fs.fh.GetFile(path, fh)
if err == os.ErrNotExist { if err == os.ErrNotExist {
logrus.WithField("path", path).Error("file not found on READ operation") log.Error().Str("path", path).Msg("file not found on READ operation")
return -fuse.ENOENT return -fuse.ENOENT
} }
if err != nil { if err != nil {
logrus.WithError(err).WithField("path", path).Error("error getting holder reading data from file") log.Error().Err(err).Str("path", path).Msg("error getting holder reading data from file")
return -fuse.EIO return -fuse.EIO
} }
@ -90,7 +90,7 @@ func (fs *FS) Read(path string, dest []byte, off int64, fh uint64) int {
n, err := file.ReadAt(buf, off) n, err := file.ReadAt(buf, off)
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
logrus.WithError(err).WithField("path", path).Error("error reading data") log.Error().Err(err).Str("path", path).Msg("error reading data")
return -fuse.EIO return -fuse.EIO
} }
@ -101,7 +101,7 @@ func (fs *FS) Read(path string, dest []byte, off int64, fh uint64) int {
func (fs *FS) Release(path string, fh uint64) (errc int) { func (fs *FS) Release(path string, fh uint64) (errc int) {
if err := fs.fh.Remove(fh); err != nil { if err := fs.fh.Remove(fh); err != nil {
logrus.WithError(err).WithField("path", path).Error("error getting holder when releasing file") log.Error().Err(err).Str("path", path).Msg("error getting holder when releasing file")
return -fuse.EIO return -fuse.EIO
} }
@ -122,13 +122,13 @@ func (fs *FS) Readdir(path string,
//TODO improve this function to make use of fh index if possible //TODO improve this function to make use of fh index if possible
paths, err := fs.fh.ListDir(path) paths, err := fs.fh.ListDir(path)
if err != nil { if err != nil {
logrus.WithField("path", path).Error("error reading directory") log.Error().Str("path", path).Msg("error reading directory")
return -fuse.EIO return -fuse.EIO
} }
for _, p := range paths { for _, p := range paths {
if !fill(p, nil, 0) { if !fill(p, nil, 0) {
logrus.WithField("path", p).Error("error adding directory") log.Error().Str("path", path).Msg("error adding directory")
break break
} }
} }

3
go.mod
View file

@ -24,14 +24,15 @@ require (
github.com/pion/srtp v1.5.2 // indirect github.com/pion/srtp v1.5.2 // indirect
github.com/pion/turn/v2 v2.0.5 // indirect github.com/pion/turn/v2 v2.0.5 // indirect
github.com/pion/webrtc/v2 v2.2.26 // indirect github.com/pion/webrtc/v2 v2.2.26 // indirect
github.com/rs/zerolog v1.20.0
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749
github.com/sirupsen/logrus v1.7.0
github.com/stretchr/testify v1.6.1 github.com/stretchr/testify v1.6.1
github.com/tinylib/msgp v1.1.4 // indirect github.com/tinylib/msgp v1.1.4 // indirect
github.com/urfave/cli/v2 v2.3.0 github.com/urfave/cli/v2 v2.3.0
github.com/willf/bitset v1.1.11 // indirect github.com/willf/bitset v1.1.11 // indirect
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9 // indirect golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9 // indirect
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 golang.org/x/net v0.0.0-20210119194325-5f4716e94777
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
google.golang.org/protobuf v1.25.0 // indirect google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776

11
go.sum
View file

@ -152,6 +152,7 @@ github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitf
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -504,6 +505,9 @@ github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rs/dnscache v0.0.0-20190621150935-06bb5526f76b h1:vQr7k9nLapW7xKl8qYc6+S5VHuhvdDF1vVzTFbWrptE= github.com/rs/dnscache v0.0.0-20190621150935-06bb5526f76b h1:vQr7k9nLapW7xKl8qYc6+S5VHuhvdDF1vVzTFbWrptE=
github.com/rs/dnscache v0.0.0-20190621150935-06bb5526f76b/go.mod h1:qe5TWALJ8/a1Lqznoc5BDHpYX/8HU60Hm2AwRmqzxqA= github.com/rs/dnscache v0.0.0-20190621150935-06bb5526f76b/go.mod h1:qe5TWALJ8/a1Lqznoc5BDHpYX/8HU60Hm2AwRmqzxqA=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.20.0 h1:38k9hgtUBdxFwE34yS8rTHmHBa4eN16E4DJlv177LNs=
github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo=
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
@ -538,11 +542,8 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5I
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20190215210624-980c5ac6f3ac/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20190215210624-980c5ac6f3ac/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
@ -703,7 +704,6 @@ golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b h1:3S2h5FadpNr0zUUCVZjlKIEYF
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191126131656-8a8471f7e56d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191126131656-8a8471f7e56d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -723,6 +723,8 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY=
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -750,6 +752,7 @@ golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200928182047-19e03678916f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20200928182047-19e03678916f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=

View file

@ -9,8 +9,8 @@ import (
"github.com/distribyted/distribyted/stats" "github.com/distribyted/distribyted/stats"
"github.com/gin-contrib/static" "github.com/gin-contrib/static"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"github.com/shurcooL/httpfs/html/vfstemplate" "github.com/shurcooL/httpfs/html/vfstemplate"
"github.com/sirupsen/logrus"
) )
func New(fc *filecache.Cache, ss *stats.Torrent, ch *config.Handler, port int) error { func New(fc *filecache.Cache, ss *stats.Torrent, ch *config.Handler, port int) error {
@ -44,7 +44,7 @@ func New(fc *filecache.Cache, ss *stats.Torrent, ch *config.Handler, port int) e
api.GET("/events", apiStreamEvents(eventChan)) api.GET("/events", apiStreamEvents(eventChan))
} }
logrus.WithField("host", fmt.Sprintf("0.0.0.0:%d", port)).Info("starting webserver") log.Info().Str("host", fmt.Sprintf("0.0.0.0:%d", port)).Msg("starting webserver")
if err := r.Run(fmt.Sprintf(":%d", port)); err != nil { if err := r.Run(fmt.Sprintf(":%d", port)); err != nil {
return fmt.Errorf("error initializing server: %w", err) return fmt.Errorf("error initializing server: %w", err)

View file

@ -8,7 +8,7 @@ import (
"github.com/distribyted/distribyted/config" "github.com/distribyted/distribyted/config"
"github.com/distribyted/distribyted/fs" "github.com/distribyted/distribyted/fs"
"github.com/distribyted/distribyted/stats" "github.com/distribyted/distribyted/stats"
log "github.com/sirupsen/logrus" "github.com/rs/zerolog/log"
) )
type Handler struct { type Handler struct {
@ -49,14 +49,14 @@ func (s *Handler) Load(path string, ts []*config.Torrent) error {
// only get info if name is not available // only get info if name is not available
if t.Name() == "" { if t.Name() == "" {
log.WithField("hash", t.InfoHash()).Info("getting torrent info") log.Info().Str("hash", t.InfoHash().String()).Msg("getting torrent info")
<-t.GotInfo() <-t.GotInfo()
} }
s.s.Add(path, t) s.s.Add(path, t)
torrents = append(torrents, t) torrents = append(torrents, t)
log.WithField("name", t.Name()).WithField("path", path).Info("torrent added to mountpoint") log.Info().Str("name", t.Name()).Str("path", path).Msg("torrent added to mountpoint")
} }
folder := path folder := path

View file

@ -5,10 +5,10 @@ import (
"net/http" "net/http"
"github.com/distribyted/distribyted/fs" "github.com/distribyted/distribyted/fs"
"github.com/sirupsen/logrus" "github.com/rs/zerolog/log"
) )
func NewWebDAVServer(fss map[string]fs.Filesystem, port int) error { func NewWebDAVServer(fss map[string]fs.Filesystem, port int) error {
logrus.WithField("host", fmt.Sprintf("0.0.0.0:%d", port)).Info("starting webDAV server") log.Info().Str("host", fmt.Sprintf("0.0.0.0:%d", port)).Msg("starting webDAV server")
return http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", port), newHandler(fss)) return http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", port), newHandler(fss))
} }