diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 78e8350edd..52d0ad166c 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -159,7 +159,7 @@ func Start(o ...Option) error { FailureBackoff: 3 * time.Second, }) - // reva storages have their own logging. For consistency sake the top level logging will cascade to reva. + // 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 diff --git a/proxy/pkg/command/proxy_example_config.yaml b/proxy/pkg/command/proxy_example_config.yaml index 0c2bff022d..4cfb08b5d5 100644 --- a/proxy/pkg/command/proxy_example_config.yaml +++ b/proxy/pkg/command/proxy_example_config.yaml @@ -1,6 +1,6 @@ -log: - level: info - color: true - pretty: true +#log: +# level: debug +# color: false +# pretty: false http: addr: "${PROXY_HTTP_ADDR|localhost:2222}" diff --git a/proxy/pkg/command/root.go b/proxy/pkg/command/root.go index fcba39fd32..eab14795d3 100644 --- a/proxy/pkg/command/root.go +++ b/proxy/pkg/command/root.go @@ -78,15 +78,12 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error { // TODO(refs) load from expected locations with the expected name err := cnf.LoadFiles("/Users/aunger/code/owncloud/ocis/proxy/pkg/command/proxy_example_config.yaml") if err != nil { - panic(err) + return err } // bind all keys to cfg, as we expect an entire proxy.[yaml, toml...] to define all keys and not only sub values. err = cnf.BindStruct("", cfg) - // step 2: overwrite the config values with those from ENV variables. Sadly the library only parses config files and does - // not support tags for env variables. - return nil } @@ -97,10 +94,10 @@ type SutureService struct { // NewSutureService creates a new proxy.SutureService func NewSutureService(cfg *ociscfg.Config) suture.Service { + inheritLogging(cfg) if cfg.Mode == 0 { cfg.Proxy.Supervised = true } - cfg.Proxy.Log.File = cfg.Log.File return SutureService{ cfg: cfg.Proxy, } @@ -114,3 +111,13 @@ func (s SutureService) Serve(ctx context.Context) error { return nil } + +// inheritLogging is a poor man's global logging state tip-toeing around circular dependencies. It sets the logging +// of the service to whatever is in the higher config (in this case coming from ocis.yaml) and sets them as defaults, +// being overwritten when the extension parses its config file / env variables. +func inheritLogging(cfg *ociscfg.Config) { + cfg.Proxy.Log.File = cfg.Log.File + cfg.Proxy.Log.Color = cfg.Log.Color + cfg.Proxy.Log.Pretty = cfg.Log.Pretty + cfg.Proxy.Log.Level = cfg.Log.Level +}