Skip to content

Commit

Permalink
Use the initialized logger in decomposedfs instead of creating our own
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Nov 21, 2024
1 parent 435a058 commit 7183397
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/storage/fs/ocis/ocis.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func init() {

// New returns an implementation to of the storage.FS interface that talk to
// a local filesystem.
func New(m map[string]interface{}, stream events.Stream, _ *zerolog.Logger) (storage.FS, error) {
func New(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (storage.FS, error) {
o, err := options.New(m)
if err != nil {
return nil, err
Expand All @@ -47,5 +47,5 @@ func New(m map[string]interface{}, stream events.Stream, _ *zerolog.Logger) (sto
return nil, err
}

return decomposedfs.NewDefault(m, bs, stream)
return decomposedfs.NewDefault(m, bs, stream, log)
}
2 changes: 1 addition & 1 deletion pkg/storage/fs/posix/posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func New(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (s
Trashbin: trashbin,
}

dfs, err := decomposedfs.New(&o.Options, aspects)
dfs, err := decomposedfs.New(&o.Options, aspects, log)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/fs/s3ng/s3ng.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func init() {

// New returns an implementation to of the storage.FS interface that talk to
// a local filesystem.
func New(m map[string]interface{}, stream events.Stream, _ *zerolog.Logger) (storage.FS, error) {
func New(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (storage.FS, error) {
o, err := parseConfig(m)
if err != nil {
return nil, err
Expand All @@ -59,5 +59,5 @@ func New(m map[string]interface{}, stream events.Stream, _ *zerolog.Logger) (sto
return nil, err
}

return decomposedfs.NewDefault(m, bs, stream)
return decomposedfs.NewDefault(m, bs, stream, log)
}
12 changes: 7 additions & 5 deletions pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/jellydator/ttlcache/v2"
"github.com/pkg/errors"
"github.com/rs/zerolog"
tusd "github.com/tus/tusd/v2/pkg/handler"
microstore "go-micro.dev/v4/store"
"go.opentelemetry.io/otel"
Expand Down Expand Up @@ -125,10 +126,12 @@ type Decomposedfs struct {
userSpaceIndex *spaceidindex.Index
groupSpaceIndex *spaceidindex.Index
spaceTypeIndex *spaceidindex.Index

log *zerolog.Logger
}

// NewDefault returns an instance with default components
func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream) (storage.FS, error) {
func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream, log *zerolog.Logger) (storage.FS, error) {
o, err := options.New(m)
if err != nil {
return nil, err
Expand Down Expand Up @@ -169,14 +172,12 @@ func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream) (
Trashbin: &DecomposedfsTrashbin{},
}

return New(o, aspects)
return New(o, aspects, log)
}

// New returns an implementation of the storage.FS interface that talks to
// a local filesystem.
func New(o *options.Options, aspects aspects.Aspects) (storage.FS, error) {
log := logger.New()

func New(o *options.Options, aspects aspects.Aspects, log *zerolog.Logger) (storage.FS, error) {
err := aspects.Tree.Setup()
if err != nil {
log.Error().Err(err).Msg("could not setup tree")
Expand Down Expand Up @@ -235,6 +236,7 @@ func New(o *options.Options, aspects aspects.Aspects) (storage.FS, error) {
userSpaceIndex: userSpaceIndex,
groupSpaceIndex: groupSpaceIndex,
spaceTypeIndex: spaceTypeIndex,
log: log,
}
fs.sessionStore = upload.NewSessionStore(fs, aspects, o.Root, o.AsyncFileUploads, o.Tokens)
if err = fs.trashbin.Setup(fs); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/decomposedfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var _ = Describe("Decomposed", func() {
_, err := decomposedfs.NewDefault(map[string]interface{}{
"root": env.Root,
"permissionssvc": "any",
}, bs, nil)
}, bs, nil, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Expand Down

0 comments on commit 7183397

Please sign in to comment.