diff --git a/services/idm/pkg/command/health.go b/services/idm/pkg/command/health.go index 050dd35e2..31d0ab6a4 100644 --- a/services/idm/pkg/command/health.go +++ b/services/idm/pkg/command/health.go @@ -5,9 +5,9 @@ import ( "net/http" "github.com/opencloud-eu/opencloud/pkg/config/configlog" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/services/idm/pkg/config" "github.com/opencloud-eu/opencloud/services/idm/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/idm/pkg/logging" "github.com/spf13/cobra" ) @@ -21,7 +21,7 @@ func Health(cfg *config.Config) *cobra.Command { return configlog.ReturnError(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) resp, err := http.Get( fmt.Sprintf( diff --git a/services/idm/pkg/command/resetpw.go b/services/idm/pkg/command/resetpw.go index 1f31065cd..b172c403b 100644 --- a/services/idm/pkg/command/resetpw.go +++ b/services/idm/pkg/command/resetpw.go @@ -12,7 +12,6 @@ import ( "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/services/idm/pkg/config" "github.com/opencloud-eu/opencloud/services/idm/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/idm/pkg/logging" "github.com/go-ldap/ldap/v3" "github.com/libregraph/idm/pkg/ldbbolt" @@ -31,7 +30,7 @@ func ResetPassword(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) ctx, cancel := context.WithCancel(cmd.Context()) defer cancel() diff --git a/services/idm/pkg/command/server.go b/services/idm/pkg/command/server.go index a71991563..1d2ddbf09 100644 --- a/services/idm/pkg/command/server.go +++ b/services/idm/pkg/command/server.go @@ -17,7 +17,6 @@ import ( "github.com/opencloud-eu/opencloud/services/idm" "github.com/opencloud-eu/opencloud/services/idm/pkg/config" "github.com/opencloud-eu/opencloud/services/idm/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/idm/pkg/logging" "github.com/opencloud-eu/opencloud/services/idm/pkg/server/debug" "github.com/go-ldap/ldif" @@ -43,7 +42,7 @@ func Server(cfg *config.Config) *cobra.Command { } ctx := cfg.Context - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel) gr := runner.NewGroup() { diff --git a/services/idm/pkg/config/config.go b/services/idm/pkg/config/config.go index 173c6f480..6dd543835 100644 --- a/services/idm/pkg/config/config.go +++ b/services/idm/pkg/config/config.go @@ -12,8 +12,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `mapstructure:"level" env:"OC_LOG_LEVEL;IDM_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` IDM Settings `yaml:"idm"` CreateDemoUsers bool `yaml:"create_demo_users" env:"IDM_CREATE_DEMO_USERS" desc:"Flag to enable or disable the creation of the demo users." introductionVersion:"1.0.0"` diff --git a/services/idm/pkg/config/defaults/defaultconfig.go b/services/idm/pkg/config/defaults/defaultconfig.go index 0bf7b8afb..225cd9357 100644 --- a/services/idm/pkg/config/defaults/defaultconfig.go +++ b/services/idm/pkg/config/defaults/defaultconfig.go @@ -40,16 +40,8 @@ func DefaultConfig() *config.Config { // EnsureDefaults adds default values to the configuration if they are not set yet 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.AdminUserID == "" && cfg.Commons != nil { diff --git a/services/idm/pkg/config/log.go b/services/idm/pkg/config/log.go deleted file mode 100644 index ebcd31aa5..000000000 --- a/services/idm/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;IDM_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;IDM_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;IDM_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;IDM_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/idm/pkg/logging/logging.go b/services/idm/pkg/logging/logging.go deleted file mode 100644 index e989ed807..000000000 --- a/services/idm/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/idm/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), - ) -}