From 419edec7cc60c8e3f0bd47eedd7916b353b510de Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Thu, 8 Jan 2026 13:06:42 +0100 Subject: [PATCH] consolidate log config in ocm Signed-off-by: Christian Richter --- services/ocm/pkg/command/server.go | 4 ++-- services/ocm/pkg/config/config.go | 4 ++-- .../ocm/pkg/config/defaults/defaultconfig.go | 12 ++---------- services/ocm/pkg/config/log.go | 9 --------- services/ocm/pkg/logging/logging.go | 17 ----------------- 5 files changed, 6 insertions(+), 40 deletions(-) delete mode 100644 services/ocm/pkg/config/log.go delete mode 100644 services/ocm/pkg/logging/logging.go diff --git a/services/ocm/pkg/command/server.go b/services/ocm/pkg/command/server.go index dbb6d8ab13..b6d06ed897 100644 --- a/services/ocm/pkg/command/server.go +++ b/services/ocm/pkg/command/server.go @@ -6,13 +6,13 @@ import ( "os/signal" "github.com/opencloud-eu/opencloud/pkg/config/configlog" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/pkg/registry" "github.com/opencloud-eu/opencloud/pkg/runner" "github.com/opencloud-eu/opencloud/pkg/tracing" "github.com/opencloud-eu/opencloud/pkg/version" "github.com/opencloud-eu/opencloud/services/ocm/pkg/config" "github.com/opencloud-eu/opencloud/services/ocm/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/ocm/pkg/logging" "github.com/opencloud-eu/opencloud/services/ocm/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/ocm/pkg/server/debug" "github.com/opencloud-eu/reva/v2/cmd/revad/runtime" @@ -29,7 +29,7 @@ func Server(cfg *config.Config) *cobra.Command { return configlog.ReturnFatal(parser.ParseConfig(cfg)) }, RunE: func(cmd *cobra.Command, args []string) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel) traceProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name) if err != nil { return err diff --git a/services/ocm/pkg/config/config.go b/services/ocm/pkg/config/config.go index 1ebff7ea52..b9a36906b8 100644 --- a/services/ocm/pkg/config/config.go +++ b/services/ocm/pkg/config/config.go @@ -15,8 +15,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;OCM_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` HTTP HTTPConfig `yaml:"http"` Middleware Middleware `yaml:"middleware"` diff --git a/services/ocm/pkg/config/defaults/defaultconfig.go b/services/ocm/pkg/config/defaults/defaultconfig.go index 5af3d3e86a..3042c94c59 100644 --- a/services/ocm/pkg/config/defaults/defaultconfig.go +++ b/services/ocm/pkg/config/defaults/defaultconfig.go @@ -140,16 +140,8 @@ func DefaultConfig() *config.Config { // EnsureDefaults ensures the config contains default values func EnsureDefaults(cfg *config.Config) { - // provide with defaults for shared logging, since we need a valid destination address for "envdecode". - if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil { - cfg.Log = &config.Log{ - Level: cfg.Commons.Log.Level, - Pretty: cfg.Commons.Log.Pretty, - Color: cfg.Commons.Log.Color, - File: cfg.Commons.Log.File, - } - } else if cfg.Log == nil { - cfg.Log = &config.Log{} + if cfg.LogLevel == "" { + cfg.LogLevel = "error" } if cfg.Reva == nil && cfg.Commons != nil { diff --git a/services/ocm/pkg/config/log.go b/services/ocm/pkg/config/log.go deleted file mode 100644 index 45b91ca14b..0000000000 --- a/services/ocm/pkg/config/log.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OC_LOG_LEVEL;OCM_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` - Pretty bool `mapstructure:"pretty" env:"OC_LOG_PRETTY;OCM_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;OCM_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;OCM_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/ocm/pkg/logging/logging.go b/services/ocm/pkg/logging/logging.go deleted file mode 100644 index 6ff4a3a3e3..0000000000 --- a/services/ocm/pkg/logging/logging.go +++ /dev/null @@ -1,17 +0,0 @@ -package logging - -import ( - "github.com/opencloud-eu/opencloud/pkg/log" - "github.com/opencloud-eu/opencloud/services/ocm/pkg/config" -) - -// Configure initializes a service-specific logger instance. -func Configure(name string, cfg *config.Log) log.Logger { - return log.NewLogger( - log.Name(name), - log.Level(cfg.Level), - log.Pretty(cfg.Pretty), - log.Color(cfg.Color), - log.File(cfg.File), - ) -}