diff --git a/services/auth-app/pkg/command/health.go b/services/auth-app/pkg/command/health.go index fac1ec71a6..9082c54b01 100644 --- a/services/auth-app/pkg/command/health.go +++ b/services/auth-app/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/auth-app/pkg/config" "github.com/opencloud-eu/opencloud/services/auth-app/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/auth-app/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/auth-app/pkg/command/server.go b/services/auth-app/pkg/command/server.go index 276bef46dd..ed8d87f334 100644 --- a/services/auth-app/pkg/command/server.go +++ b/services/auth-app/pkg/command/server.go @@ -6,6 +6,7 @@ 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" ogrpc "github.com/opencloud-eu/opencloud/pkg/service/grpc" @@ -14,7 +15,6 @@ import ( settingssvc "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/services/settings/v0" "github.com/opencloud-eu/opencloud/services/auth-app/pkg/config" "github.com/opencloud-eu/opencloud/services/auth-app/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/auth-app/pkg/logging" "github.com/opencloud-eu/opencloud/services/auth-app/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/auth-app/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/auth-app/pkg/server/http" @@ -37,7 +37,7 @@ func Server(cfg *config.Config) *cobra.Command { fmt.Println("WARNING: Impersonation is enabled. Admins can impersonate all users.") } - 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/auth-app/pkg/config/config.go b/services/auth-app/pkg/config/config.go index 0ec52de4a9..9cda13a362 100644 --- a/services/auth-app/pkg/config/config.go +++ b/services/auth-app/pkg/config/config.go @@ -8,10 +8,10 @@ import ( // Config defines the root config structure type Config struct { - Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service - Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service + Service Service `yaml:"-"` + LogLevel string `yaml:"level" env:"OC_LOG_LEVEL;AUTH_APP_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` GRPC GRPCConfig `yaml:"grpc"` HTTP HTTP `yaml:"http"` @@ -61,14 +61,6 @@ type RandPWOpts struct { PasswordLength int `yaml:"password_length" env:"AUTH_APP_JSONCS3_RANDOM_PASSWORD_LENGTH" desc:"The number of charactors the generated passwords will have." introductionVersion:"4.0.0"` } -// Log defines the loging configuration -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;AUTH_APP_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` - Pretty bool `yaml:"pretty" env:"OC_LOG_PRETTY;AUTH_APP_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;AUTH_APP_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;AUTH_APP_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - // Service defines the service configuration type Service struct { Name string `yaml:"-"` diff --git a/services/auth-app/pkg/config/defaults/defaultconfig.go b/services/auth-app/pkg/config/defaults/defaultconfig.go index 3acce5d06c..9bce1f8c02 100644 --- a/services/auth-app/pkg/config/defaults/defaultconfig.go +++ b/services/auth-app/pkg/config/defaults/defaultconfig.go @@ -63,16 +63,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.GRPCClientTLS == nil && cfg.Commons != nil { diff --git a/services/auth-app/pkg/logging/logging.go b/services/auth-app/pkg/logging/logging.go deleted file mode 100644 index f9af2a136a..0000000000 --- a/services/auth-app/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/auth-app/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), - ) -}