From 7eb2c25d653647836c8b25e994db600d9375c255 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Thu, 11 Nov 2021 13:58:19 +0100 Subject: [PATCH] propagate storage common logging config --- ocis/pkg/runtime/service/service.go | 8 +------- storage/pkg/command/appprovider.go | 4 +--- storage/pkg/command/authbasic.go | 4 +--- storage/pkg/command/authbearer.go | 4 +--- storage/pkg/command/authmachine.go | 4 +--- storage/pkg/command/frontend.go | 6 ++---- storage/pkg/command/gateway.go | 4 +--- storage/pkg/command/groups.go | 4 +--- storage/pkg/command/sharing.go | 4 +--- storage/pkg/command/storagehome.go | 4 +--- storage/pkg/command/storagemetadata.go | 4 +--- storage/pkg/command/storagepubliclink.go | 4 +--- storage/pkg/command/storageusers.go | 4 +--- storage/pkg/command/users.go | 4 +--- storage/pkg/config/config.go | 12 +++++++++--- 15 files changed, 24 insertions(+), 50 deletions(-) diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 52d0ad166c..4313a14730 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -159,13 +159,7 @@ func Start(o ...Option) error { FailureBackoff: 3 * time.Second, }) - // reva storages have their own logging. For consistency's sake the top level logging will cascade to reva. - s.cfg.Storage.Log.Color = s.cfg.Log.Color - s.cfg.Storage.Log.Level = s.cfg.Log.Level - s.cfg.Storage.Log.Pretty = s.cfg.Log.Pretty - s.cfg.Storage.Log.File = s.cfg.Log.File - - if err := rpc.Register(s); err != nil { + if err = rpc.Register(s); err != nil { if s != nil { s.Log.Fatal().Err(err) } diff --git a/storage/pkg/command/appprovider.go b/storage/pkg/command/appprovider.go index 1a8b9e5d95..59c0684ec0 100644 --- a/storage/pkg/command/appprovider.go +++ b/storage/pkg/command/appprovider.go @@ -132,9 +132,7 @@ type AppProviderSutureService struct { // NewAppProvider creates a new store.AppProviderSutureService func NewAppProvider(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.AppProvider.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return AppProviderSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/authbasic.go b/storage/pkg/command/authbasic.go index 840963058d..cd9ac7977d 100644 --- a/storage/pkg/command/authbasic.go +++ b/storage/pkg/command/authbasic.go @@ -151,9 +151,7 @@ type AuthBasicSutureService struct { // NewAuthBasicSutureService creates a new store.AuthBasicSutureService func NewAuthBasic(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.AuthBasic.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return AuthBasicSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/authbearer.go b/storage/pkg/command/authbearer.go index 4a2b43c05e..4c8d87463a 100644 --- a/storage/pkg/command/authbearer.go +++ b/storage/pkg/command/authbearer.go @@ -127,9 +127,7 @@ type AuthBearerSutureService struct { // NewAuthBearerSutureService creates a new gateway.AuthBearerSutureService func NewAuthBearer(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.AuthBearer.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return AuthBearerSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/authmachine.go b/storage/pkg/command/authmachine.go index 8bdb111014..9a0244895a 100644 --- a/storage/pkg/command/authmachine.go +++ b/storage/pkg/command/authmachine.go @@ -123,9 +123,7 @@ type AuthMachineSutureService struct { // NewAuthMachineSutureService creates a new gateway.AuthMachineSutureService func NewAuthMachine(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.AuthMachine.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return AuthMachineSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index 19822f7f28..314d1e149b 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -335,11 +335,9 @@ type FrontendSutureService struct { cfg *config.Config } -// NewFrontendSutureService creates a new frontend.FrontendSutureService +// NewFrontend creates a new frontend.FrontendSutureService func NewFrontend(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.Frontend.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return FrontendSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/gateway.go b/storage/pkg/command/gateway.go index b1047367fb..f684083429 100644 --- a/storage/pkg/command/gateway.go +++ b/storage/pkg/command/gateway.go @@ -351,9 +351,7 @@ type GatewaySutureService struct { // NewGatewaySutureService creates a new gateway.GatewaySutureService func NewGateway(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.Gateway.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return GatewaySutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/groups.go b/storage/pkg/command/groups.go index e3758080f7..4142c8e9a1 100644 --- a/storage/pkg/command/groups.go +++ b/storage/pkg/command/groups.go @@ -165,9 +165,7 @@ type GroupSutureService struct { // NewGroupProviderSutureService creates a new storage.GroupProvider func NewGroupProvider(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.Groups.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return GroupSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/sharing.go b/storage/pkg/command/sharing.go index 50f50c64b6..c23455eb43 100644 --- a/storage/pkg/command/sharing.go +++ b/storage/pkg/command/sharing.go @@ -191,9 +191,7 @@ type SharingSutureService struct { // NewSharingSutureService creates a new store.SharingSutureService func NewSharing(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.Sharing.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return SharingSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storagehome.go b/storage/pkg/command/storagehome.go index fff984b13c..1ab83572a6 100644 --- a/storage/pkg/command/storagehome.go +++ b/storage/pkg/command/storagehome.go @@ -150,9 +150,7 @@ type StorageHomeSutureService struct { // NewStorageHomeSutureService creates a new storage.StorageHomeSutureService func NewStorageHome(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.StorageHome.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return StorageHomeSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storagemetadata.go b/storage/pkg/command/storagemetadata.go index 29cd5deb1c..665d4606ab 100644 --- a/storage/pkg/command/storagemetadata.go +++ b/storage/pkg/command/storagemetadata.go @@ -166,9 +166,7 @@ type MetadataSutureService struct { // NewSutureService creates a new storagemetadata.SutureService func NewStorageMetadata(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.StorageMetadata.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return MetadataSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storagepubliclink.go b/storage/pkg/command/storagepubliclink.go index d90b971fc0..d5bb031c79 100644 --- a/storage/pkg/command/storagepubliclink.go +++ b/storage/pkg/command/storagepubliclink.go @@ -124,9 +124,7 @@ type StoragePublicLinkSutureService struct { // NewStoragePublicLinkSutureService creates a new storage.StoragePublicLinkSutureService func NewStoragePublicLink(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.StoragePublicLink.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return StoragePublicLinkSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/storageusers.go b/storage/pkg/command/storageusers.go index 99ae03348c..51b48508d3 100644 --- a/storage/pkg/command/storageusers.go +++ b/storage/pkg/command/storageusers.go @@ -150,9 +150,7 @@ type StorageUsersSutureService struct { // NewStorageUsersSutureService creates a new storage.StorageUsersSutureService func NewStorageUsers(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.StorageUsers.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return StorageUsersSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/command/users.go b/storage/pkg/command/users.go index 2f4c3e87cc..60115b8757 100644 --- a/storage/pkg/command/users.go +++ b/storage/pkg/command/users.go @@ -186,9 +186,7 @@ type UserProviderSutureService struct { // NewUserProviderSutureService creates a new storage.UserProvider func NewUserProvider(cfg *ociscfg.Config) suture.Service { - if cfg.Mode == 0 { - cfg.Storage.Reva.Users.Supervised = true - } + cfg.Storage.Log = cfg.Commons.Log return UserProviderSutureService{ cfg: cfg.Storage, } diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 4797b77362..7b34ec6470 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -1,6 +1,10 @@ package config -import "context" +import ( + "context" + + "github.com/owncloud/ocis/ocis-pkg/shared" +) // Log defines the available logging configuration. type Log struct { @@ -497,7 +501,7 @@ type Asset struct { // Config combines all available configuration parts. type Config struct { File string - Log Log + Log *shared.Log Debug Debug Reva Reva Tracing Tracing @@ -506,5 +510,7 @@ type Config struct { // New initializes a new configuration with or without defaults. func New() *Config { - return &Config{} + return &Config{ + Log: &shared.Log{}, + } }