diff --git a/pkg/log/config.go b/pkg/log/config.go new file mode 100644 index 0000000000..0bb4db1b50 --- /dev/null +++ b/pkg/log/config.go @@ -0,0 +1,14 @@ +package log + +import "github.com/opencloud-eu/opencloud/pkg/shared" + +// Configure initializes a service-specific logger instance. +func Configure(name string, commons *shared.Commons, localServiceLogLevel string) Logger { + return NewLogger( + Name(name), + Level(localServiceLogLevel), + Pretty(commons.Log.Pretty), + Color(commons.Log.Color), + File(commons.Log.File), + ) +} diff --git a/services/activitylog/pkg/command/server.go b/services/activitylog/pkg/command/server.go index ec86ee9b4f..8f95d481f9 100644 --- a/services/activitylog/pkg/command/server.go +++ b/services/activitylog/pkg/command/server.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/oklog/run" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/reva/v2/pkg/events" "github.com/opencloud-eu/reva/v2/pkg/events/stream" "github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool" @@ -22,7 +23,6 @@ import ( settingssvc "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/services/settings/v0" "github.com/opencloud-eu/opencloud/services/activitylog/pkg/config" "github.com/opencloud-eu/opencloud/services/activitylog/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/activitylog/pkg/logging" "github.com/opencloud-eu/opencloud/services/activitylog/pkg/metrics" "github.com/opencloud-eu/opencloud/services/activitylog/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/activitylog/pkg/server/http" @@ -55,7 +55,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) tracerProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name) if err != nil { logger.Error().Err(err).Msg("Failed to initialize tracer") diff --git a/services/activitylog/pkg/config/config.go b/services/activitylog/pkg/config/config.go index d518bffcad..3e904571c9 100644 --- a/services/activitylog/pkg/config/config.go +++ b/services/activitylog/pkg/config/config.go @@ -13,7 +13,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;ACTIVITYLOG_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` Events Events `yaml:"events"` diff --git a/services/activitylog/pkg/config/defaults/defaultconfig.go b/services/activitylog/pkg/config/defaults/defaultconfig.go index a6da0cf297..7265cd56eb 100644 --- a/services/activitylog/pkg/config/defaults/defaultconfig.go +++ b/services/activitylog/pkg/config/defaults/defaultconfig.go @@ -59,18 +59,9 @@ 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.GRPCClientTLS == nil && cfg.Commons != nil { cfg.GRPCClientTLS = structs.CopyOrZeroValue(cfg.Commons.GRPCClientTLS) } diff --git a/services/activitylog/pkg/config/log.go b/services/activitylog/pkg/config/log.go deleted file mode 100644 index cd5e4cb109..0000000000 --- a/services/activitylog/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;ACTIVITYLOG_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;ACTIVITYLOG_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;ACTIVITYLOG_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;ACTIVITYLOG_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/activitylog/pkg/logging/logging.go b/services/activitylog/pkg/logging/logging.go deleted file mode 100644 index 7994b741a4..0000000000 --- a/services/activitylog/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/activitylog/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), - ) -} diff --git a/services/antivirus/pkg/command/health.go b/services/antivirus/pkg/command/health.go index 937f7b2df8..a3c5df8de6 100644 --- a/services/antivirus/pkg/command/health.go +++ b/services/antivirus/pkg/command/health.go @@ -21,13 +21,7 @@ func Health(cfg *config.Config) *cobra.Command { return configlog.ReturnError(parser.ParseConfig(cfg)) }, RunE: func(cmd *cobra.Command, args []string) error { - logger := log.NewLogger( - log.Name(cfg.Service.Name), - log.Level(cfg.Log.Level), - log.Pretty(cfg.Log.Pretty), - log.Color(cfg.Log.Color), - log.File(cfg.Log.File), - ) + logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel) resp, err := http.Get( fmt.Sprintf( diff --git a/services/antivirus/pkg/command/server.go b/services/antivirus/pkg/command/server.go index dd6aa6e223..283bbd0934 100644 --- a/services/antivirus/pkg/command/server.go +++ b/services/antivirus/pkg/command/server.go @@ -32,14 +32,7 @@ func Server(cfg *config.Config) *cobra.Command { defer cancel() } ctx := cfg.Context - - logger := log.NewLogger( - log.Name(cfg.Service.Name), - log.Level(cfg.Log.Level), - log.Pretty(cfg.Log.Pretty), - log.Color(cfg.Log.Color), - log.File(cfg.Log.File), - ) + 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 { diff --git a/services/antivirus/pkg/config/config.go b/services/antivirus/pkg/config/config.go index c0a25c0904..32f89eb0b5 100644 --- a/services/antivirus/pkg/config/config.go +++ b/services/antivirus/pkg/config/config.go @@ -29,11 +29,10 @@ const ( // Config combines all available configuration parts. type Config struct { - Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service - File string - Log *Log - - Debug Debug `yaml:"debug" mask:"struct"` + Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service + File string + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;ANTIVIRUS_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug" mask:"struct"` Service Service `yaml:"-"` @@ -55,14 +54,6 @@ type Service struct { Name string `yaml:"-"` } -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OC_LOG_LEVEL;ANTIVIRUS_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;ANTIVIRUS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;ANTIVIRUS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;ANTIVIRUS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - // Debug defines the available debug configuration. type Debug struct { Addr string `yaml:"addr" env:"ANTIVIRUS_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed." introductionVersion:"1.0.0"` diff --git a/services/antivirus/pkg/config/defaults/defaultconfig.go b/services/antivirus/pkg/config/defaults/defaultconfig.go index 446e7c215b..7b912d588c 100644 --- a/services/antivirus/pkg/config/defaults/defaultconfig.go +++ b/services/antivirus/pkg/config/defaults/defaultconfig.go @@ -51,8 +51,8 @@ func DefaultConfig() *config.Config { // EnsureDefaults adds default values to the configuration if they are not set yet func EnsureDefaults(cfg *config.Config) { - if cfg.Log == nil { - cfg.Log = &config.Log{} + if cfg.LogLevel == "" { + cfg.LogLevel = "error" } } diff --git a/services/app-provider/pkg/command/health.go b/services/app-provider/pkg/command/health.go index 9668bd4cd8..e1daa95b07 100644 --- a/services/app-provider/pkg/command/health.go +++ b/services/app-provider/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/app-provider/pkg/config" "github.com/opencloud-eu/opencloud/services/app-provider/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/app-provider/pkg/logging" "github.com/spf13/cobra" ) @@ -20,7 +20,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/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index a615dd0c4f..e303439958 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -5,6 +5,7 @@ import ( "fmt" "os/signal" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/reva/v2/cmd/revad/runtime" "github.com/spf13/cobra" @@ -15,7 +16,6 @@ import ( "github.com/opencloud-eu/opencloud/pkg/version" "github.com/opencloud-eu/opencloud/services/app-provider/pkg/config" "github.com/opencloud-eu/opencloud/services/app-provider/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/app-provider/pkg/logging" "github.com/opencloud-eu/opencloud/services/app-provider/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/app-provider/pkg/server/debug" ) @@ -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/app-provider/pkg/config/config.go b/services/app-provider/pkg/config/config.go index ee89e56083..e638a2678f 100644 --- a/services/app-provider/pkg/config/config.go +++ b/services/app-provider/pkg/config/config.go @@ -7,10 +7,10 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;APP_PROVIDER_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"` @@ -24,13 +24,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;APP_PROVIDER_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;APP_PROVIDER_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;APP_PROVIDER_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;APP_PROVIDER_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Debug struct { Addr string `yaml:"addr" env:"APP_PROVIDER_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed." introductionVersion:"1.0.0"` Token string `yaml:"token" env:"APP_PROVIDER_DEBUG_TOKEN" desc:"Token to secure the metrics endpoint" introductionVersion:"1.0.0"` diff --git a/services/app-provider/pkg/config/defaults/defaultconfig.go b/services/app-provider/pkg/config/defaults/defaultconfig.go index c33e6db4ca..4c9d64d382 100644 --- a/services/app-provider/pkg/config/defaults/defaultconfig.go +++ b/services/app-provider/pkg/config/defaults/defaultconfig.go @@ -45,16 +45,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.Reva == nil && cfg.Commons != nil { diff --git a/services/app-provider/pkg/logging/logging.go b/services/app-provider/pkg/logging/logging.go deleted file mode 100644 index c131825be2..0000000000 --- a/services/app-provider/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/app-provider/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), - ) -} diff --git a/services/app-registry/pkg/command/health.go b/services/app-registry/pkg/command/health.go index e4389443eb..bca9cedace 100644 --- a/services/app-registry/pkg/command/health.go +++ b/services/app-registry/pkg/command/health.go @@ -5,9 +5,10 @@ import ( "net/http" "github.com/opencloud-eu/opencloud/pkg/config/configlog" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/services/app-registry/pkg/config" "github.com/opencloud-eu/opencloud/services/app-registry/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/app-registry/pkg/logging" + "github.com/spf13/cobra" ) @@ -20,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/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index 4b11c872ba..e94d2e6a41 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -6,16 +6,17 @@ 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/app-registry/pkg/config" "github.com/opencloud-eu/opencloud/services/app-registry/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/app-registry/pkg/logging" "github.com/opencloud-eu/opencloud/services/app-registry/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/app-registry/pkg/server/debug" "github.com/opencloud-eu/reva/v2/cmd/revad/runtime" + "github.com/spf13/cobra" ) @@ -28,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/app-registry/pkg/config/config.go b/services/app-registry/pkg/config/config.go index a32386e8f3..38d853dfa4 100644 --- a/services/app-registry/pkg/config/config.go +++ b/services/app-registry/pkg/config/config.go @@ -9,9 +9,10 @@ import ( 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"` + Service Service `yaml:"-"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;APP_REGISTRY_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"` @@ -23,13 +24,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;APP_REGISTRY_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;APP_REGISTRY_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;APP_REGISTRY_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;APP_REGISTRY_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Service struct { Name string `yaml:"-"` } diff --git a/services/app-registry/pkg/config/defaults/defaultconfig.go b/services/app-registry/pkg/config/defaults/defaultconfig.go index 8bab2a9fb9..f04016b473 100644 --- a/services/app-registry/pkg/config/defaults/defaultconfig.go +++ b/services/app-registry/pkg/config/defaults/defaultconfig.go @@ -122,16 +122,8 @@ func defaultMimeTypeConfig() []config.MimeTypeConfig { // 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.Reva == nil && cfg.Commons != nil { diff --git a/services/app-registry/pkg/logging/logging.go b/services/app-registry/pkg/logging/logging.go deleted file mode 100644 index 5431a66b82..0000000000 --- a/services/app-registry/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/app-registry/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), - ) -} diff --git a/services/audit/pkg/command/server.go b/services/audit/pkg/command/server.go index 4ce05241da..3ebc610441 100644 --- a/services/audit/pkg/command/server.go +++ b/services/audit/pkg/command/server.go @@ -7,10 +7,10 @@ import ( "github.com/opencloud-eu/opencloud/pkg/config/configlog" "github.com/opencloud-eu/opencloud/pkg/generators" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/pkg/runner" "github.com/opencloud-eu/opencloud/services/audit/pkg/config" "github.com/opencloud-eu/opencloud/services/audit/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/audit/pkg/logging" "github.com/opencloud-eu/opencloud/services/audit/pkg/server/debug" svc "github.com/opencloud-eu/opencloud/services/audit/pkg/service" "github.com/opencloud-eu/opencloud/services/audit/pkg/types" @@ -35,8 +35,7 @@ func Server(cfg *config.Config) *cobra.Command { defer cancel() } ctx := cfg.Context - - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel) gr := runner.NewGroup() connName := generators.GenerateConnectionName(cfg.Service.Name, generators.NTypeBus) diff --git a/services/audit/pkg/config/config.go b/services/audit/pkg/config/config.go index c98fd9f215..a37826b448 100644 --- a/services/audit/pkg/config/config.go +++ b/services/audit/pkg/config/config.go @@ -8,12 +8,10 @@ import ( // Config combines all available configuration parts. 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:"loglevel" env:"OC_LOG_LEVEL;AUDIT_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` Events Events `yaml:"events"` Auditlog Auditlog `yaml:"auditlog"` diff --git a/services/audit/pkg/config/defaults/defaultconfig.go b/services/audit/pkg/config/defaults/defaultconfig.go index 20d8818928..0dbc9e5fd8 100644 --- a/services/audit/pkg/config/defaults/defaultconfig.go +++ b/services/audit/pkg/config/defaults/defaultconfig.go @@ -37,16 +37,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" } } diff --git a/services/audit/pkg/config/log.go b/services/audit/pkg/config/log.go deleted file mode 100644 index c9ffe7c970..0000000000 --- a/services/audit/pkg/config/log.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -// Log defines the available log configuration. -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;AUDIT_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;AUDIT_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;AUDIT_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;AUDIT_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/audit/pkg/logging/logging.go b/services/audit/pkg/logging/logging.go deleted file mode 100644 index 9387cf2c0d..0000000000 --- a/services/audit/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/audit/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), - ) -} 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..5435ba83a9 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:"loglevel" 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), - ) -} diff --git a/services/auth-basic/pkg/command/health.go b/services/auth-basic/pkg/command/health.go index 86c475cd8c..9eab03f1df 100644 --- a/services/auth-basic/pkg/command/health.go +++ b/services/auth-basic/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-basic/pkg/config" "github.com/opencloud-eu/opencloud/services/auth-basic/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/auth-basic/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-basic/pkg/command/server.go b/services/auth-basic/pkg/command/server.go index e690533e14..48cee21a18 100644 --- a/services/auth-basic/pkg/command/server.go +++ b/services/auth-basic/pkg/command/server.go @@ -7,13 +7,13 @@ import ( "github.com/opencloud-eu/opencloud/pkg/config/configlog" "github.com/opencloud-eu/opencloud/pkg/ldap" + "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/auth-basic/pkg/config" "github.com/opencloud-eu/opencloud/services/auth-basic/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/auth-basic/pkg/logging" "github.com/opencloud-eu/opencloud/services/auth-basic/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/auth-basic/pkg/server/debug" "github.com/opencloud-eu/reva/v2/cmd/revad/runtime" @@ -30,7 +30,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/auth-basic/pkg/config/config.go b/services/auth-basic/pkg/config/config.go index b9235895e7..933a46bfd9 100644 --- a/services/auth-basic/pkg/config/config.go +++ b/services/auth-basic/pkg/config/config.go @@ -7,10 +7,10 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;AUTH_BASIC_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"` @@ -24,13 +24,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;AUTH_BASIC_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_BASIC_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;AUTH_BASIC_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;AUTH_BASIC_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Service struct { Name string `yaml:"-"` } diff --git a/services/auth-basic/pkg/config/defaults/defaultconfig.go b/services/auth-basic/pkg/config/defaults/defaultconfig.go index 01f53a27ae..04bdf4aca8 100644 --- a/services/auth-basic/pkg/config/defaults/defaultconfig.go +++ b/services/auth-basic/pkg/config/defaults/defaultconfig.go @@ -86,18 +86,9 @@ 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.Reva == nil && cfg.Commons != nil { cfg.Reva = structs.CopyOrZeroValue(cfg.Commons.Reva) } diff --git a/services/auth-basic/pkg/logging/logging.go b/services/auth-basic/pkg/logging/logging.go deleted file mode 100644 index 61132103e0..0000000000 --- a/services/auth-basic/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-basic/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), - ) -} diff --git a/services/auth-bearer/pkg/command/health.go b/services/auth-bearer/pkg/command/health.go index 967dedd48a..bfd2e68362 100644 --- a/services/auth-bearer/pkg/command/health.go +++ b/services/auth-bearer/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-bearer/pkg/config" "github.com/opencloud-eu/opencloud/services/auth-bearer/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/auth-bearer/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-bearer/pkg/command/server.go b/services/auth-bearer/pkg/command/server.go index aeab79824f..8339354d6a 100644 --- a/services/auth-bearer/pkg/command/server.go +++ b/services/auth-bearer/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/auth-bearer/pkg/config" "github.com/opencloud-eu/opencloud/services/auth-bearer/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/auth-bearer/pkg/logging" "github.com/opencloud-eu/opencloud/services/auth-bearer/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/auth-bearer/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/auth-bearer/pkg/config/config.go b/services/auth-bearer/pkg/config/config.go index 6887362892..221a8b5772 100644 --- a/services/auth-bearer/pkg/config/config.go +++ b/services/auth-bearer/pkg/config/config.go @@ -7,10 +7,11 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;AUTH_BEARER_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"` @@ -24,13 +25,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;AUTH_BEARER_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_BEARER_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;AUTH_BEARER_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;AUTH_BEARER_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Service struct { Name string `yaml:"-"` } diff --git a/services/auth-bearer/pkg/config/defaults/defaultconfig.go b/services/auth-bearer/pkg/config/defaults/defaultconfig.go index 8bc9c99d9f..5c4ac9a065 100644 --- a/services/auth-bearer/pkg/config/defaults/defaultconfig.go +++ b/services/auth-bearer/pkg/config/defaults/defaultconfig.go @@ -42,16 +42,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.Reva == nil && cfg.Commons != nil { diff --git a/services/auth-bearer/pkg/logging/logging.go b/services/auth-bearer/pkg/logging/logging.go deleted file mode 100644 index ed5c0f02c3..0000000000 --- a/services/auth-bearer/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-bearer/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), - ) -} diff --git a/services/auth-machine/pkg/command/health.go b/services/auth-machine/pkg/command/health.go index 3051626034..09bafd7cd0 100644 --- a/services/auth-machine/pkg/command/health.go +++ b/services/auth-machine/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-machine/pkg/config" "github.com/opencloud-eu/opencloud/services/auth-machine/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/auth-machine/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-machine/pkg/command/server.go b/services/auth-machine/pkg/command/server.go index 3821939fb4..f543ece996 100644 --- a/services/auth-machine/pkg/command/server.go +++ b/services/auth-machine/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/auth-machine/pkg/config" "github.com/opencloud-eu/opencloud/services/auth-machine/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/auth-machine/pkg/logging" "github.com/opencloud-eu/opencloud/services/auth-machine/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/auth-machine/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/auth-machine/pkg/config/config.go b/services/auth-machine/pkg/config/config.go index be007ab264..3ed32c0ab7 100644 --- a/services/auth-machine/pkg/config/config.go +++ b/services/auth-machine/pkg/config/config.go @@ -7,10 +7,10 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;AUTH_MACHINE_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"` @@ -24,13 +24,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;AUTH_MACHINE_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_MACHINE_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;AUTH_MACHINE_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;AUTH_MACHINE_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Service struct { Name string `yaml:"-"` } diff --git a/services/auth-machine/pkg/config/defaults/defaultconfig.go b/services/auth-machine/pkg/config/defaults/defaultconfig.go index 17dcf313f4..d27c14fc24 100644 --- a/services/auth-machine/pkg/config/defaults/defaultconfig.go +++ b/services/auth-machine/pkg/config/defaults/defaultconfig.go @@ -37,18 +37,9 @@ 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.Reva == nil && cfg.Commons != nil { cfg.Reva = structs.CopyOrZeroValue(cfg.Commons.Reva) } diff --git a/services/auth-machine/pkg/logging/logging.go b/services/auth-machine/pkg/logging/logging.go deleted file mode 100644 index ec297533f3..0000000000 --- a/services/auth-machine/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-machine/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), - ) -} diff --git a/services/auth-service/pkg/command/health.go b/services/auth-service/pkg/command/health.go index d9124a91ac..41ef191d58 100644 --- a/services/auth-service/pkg/command/health.go +++ b/services/auth-service/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-service/pkg/config" "github.com/opencloud-eu/opencloud/services/auth-service/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/auth-service/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-service/pkg/command/server.go b/services/auth-service/pkg/command/server.go index b6a4aab21b..28aca4004f 100644 --- a/services/auth-service/pkg/command/server.go +++ b/services/auth-service/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/auth-service/pkg/config" "github.com/opencloud-eu/opencloud/services/auth-service/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/auth-service/pkg/logging" "github.com/opencloud-eu/opencloud/services/auth-service/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/auth-service/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/auth-service/pkg/config/config.go b/services/auth-service/pkg/config/config.go index 231f6bcd3d..638a78024b 100644 --- a/services/auth-service/pkg/config/config.go +++ b/services/auth-service/pkg/config/config.go @@ -7,10 +7,10 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;AUTH_SERVICE_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"` @@ -23,13 +23,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;AUTH_SERVICE_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_SERVICE_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;AUTH_SERVICE_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;AUTH_SERVICE_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Service struct { Name string `yaml:"-"` } diff --git a/services/auth-service/pkg/config/defaults/defaultconfig.go b/services/auth-service/pkg/config/defaults/defaultconfig.go index d1a9f7d08f..31cd25f209 100644 --- a/services/auth-service/pkg/config/defaults/defaultconfig.go +++ b/services/auth-service/pkg/config/defaults/defaultconfig.go @@ -37,16 +37,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.Reva == nil && cfg.Commons != nil { diff --git a/services/auth-service/pkg/logging/logging.go b/services/auth-service/pkg/logging/logging.go deleted file mode 100644 index 8098a5eb72..0000000000 --- a/services/auth-service/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-service/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), - ) -} diff --git a/services/clientlog/pkg/command/server.go b/services/clientlog/pkg/command/server.go index 6156255837..9472e072af 100644 --- a/services/clientlog/pkg/command/server.go +++ b/services/clientlog/pkg/command/server.go @@ -7,13 +7,13 @@ import ( "github.com/opencloud-eu/opencloud/pkg/config/configlog" "github.com/opencloud-eu/opencloud/pkg/generators" + "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/clientlog/pkg/config" "github.com/opencloud-eu/opencloud/services/clientlog/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/clientlog/pkg/logging" "github.com/opencloud-eu/opencloud/services/clientlog/pkg/metrics" "github.com/opencloud-eu/opencloud/services/clientlog/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/clientlog/pkg/service" @@ -55,7 +55,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) tracerProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name) if err != nil { return err diff --git a/services/clientlog/pkg/config/config.go b/services/clientlog/pkg/config/config.go index a55c81bfe7..5af2943314 100644 --- a/services/clientlog/pkg/config/config.go +++ b/services/clientlog/pkg/config/config.go @@ -12,7 +12,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;CLIENTLOG_USERLOG_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` diff --git a/services/clientlog/pkg/config/defaults/defaultconfig.go b/services/clientlog/pkg/config/defaults/defaultconfig.go index 5c615e374b..82a64072be 100644 --- a/services/clientlog/pkg/config/defaults/defaultconfig.go +++ b/services/clientlog/pkg/config/defaults/defaultconfig.go @@ -37,16 +37,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.GRPCClientTLS == nil && cfg.Commons != nil { diff --git a/services/clientlog/pkg/config/log.go b/services/clientlog/pkg/config/log.go deleted file mode 100644 index 68ce9f748f..0000000000 --- a/services/clientlog/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;CLIENTLOG_USERLOG_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;CLIENTLOG_USERLOG_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;CLIENTLOG_USERLOG_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;CLIENTLOG_USERLOG_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/clientlog/pkg/logging/logging.go b/services/clientlog/pkg/logging/logging.go deleted file mode 100644 index b8d64c41aa..0000000000 --- a/services/clientlog/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/clientlog/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), - ) -} diff --git a/services/collaboration/pkg/command/health.go b/services/collaboration/pkg/command/health.go index 35e8414d4f..d4ffcef511 100644 --- a/services/collaboration/pkg/command/health.go +++ b/services/collaboration/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/collaboration/pkg/config" "github.com/opencloud-eu/opencloud/services/collaboration/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/collaboration/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/collaboration/pkg/command/server.go b/services/collaboration/pkg/command/server.go index ea47dabe33..92e14c0972 100644 --- a/services/collaboration/pkg/command/server.go +++ b/services/collaboration/pkg/command/server.go @@ -8,6 +8,7 @@ import ( "time" "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" @@ -15,7 +16,6 @@ import ( "github.com/opencloud-eu/opencloud/services/collaboration/pkg/config/parser" "github.com/opencloud-eu/opencloud/services/collaboration/pkg/connector" "github.com/opencloud-eu/opencloud/services/collaboration/pkg/helpers" - "github.com/opencloud-eu/opencloud/services/collaboration/pkg/logging" "github.com/opencloud-eu/opencloud/services/collaboration/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/collaboration/pkg/server/grpc" "github.com/opencloud-eu/opencloud/services/collaboration/pkg/server/http" @@ -35,7 +35,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/collaboration/pkg/config/config.go b/services/collaboration/pkg/config/config.go index bdf62a8c4d..9b4594bd93 100644 --- a/services/collaboration/pkg/config/config.go +++ b/services/collaboration/pkg/config/config.go @@ -22,8 +22,8 @@ type Config struct { Wopi Wopi `yaml:"wopi"` CS3Api CS3Api `yaml:"cs3api"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;COLLABORATION_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` Context context.Context `yaml:"-"` } diff --git a/services/collaboration/pkg/config/defaults/defaultconfig.go b/services/collaboration/pkg/config/defaults/defaultconfig.go index c8119dab37..20aaf45b86 100644 --- a/services/collaboration/pkg/config/defaults/defaultconfig.go +++ b/services/collaboration/pkg/config/defaults/defaultconfig.go @@ -72,16 +72,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.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/collaboration/pkg/config/log.go b/services/collaboration/pkg/config/log.go deleted file mode 100644 index 391e6fa1ef..0000000000 --- a/services/collaboration/pkg/config/log.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -// Log defines the available log configuration. -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;COLLABORATION_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;COLLABORATION_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;COLLABORATION_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;COLLABORATION_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/collaboration/pkg/logging/logging.go b/services/collaboration/pkg/logging/logging.go deleted file mode 100644 index 0048065e15..0000000000 --- a/services/collaboration/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/collaboration/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), - ) -} diff --git a/services/eventhistory/pkg/command/server.go b/services/eventhistory/pkg/command/server.go index 94cdfc927d..d3612fc251 100644 --- a/services/eventhistory/pkg/command/server.go +++ b/services/eventhistory/pkg/command/server.go @@ -7,13 +7,13 @@ import ( "github.com/opencloud-eu/opencloud/pkg/config/configlog" "github.com/opencloud-eu/opencloud/pkg/generators" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/pkg/runner" ogrpc "github.com/opencloud-eu/opencloud/pkg/service/grpc" "github.com/opencloud-eu/opencloud/pkg/tracing" "github.com/opencloud-eu/opencloud/pkg/version" "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/config" "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/logging" "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/metrics" "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/server/grpc" @@ -33,7 +33,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/eventhistory/pkg/config/config.go b/services/eventhistory/pkg/config/config.go index 18a69b3ac5..5b93e5f2ed 100644 --- a/services/eventhistory/pkg/config/config.go +++ b/services/eventhistory/pkg/config/config.go @@ -14,8 +14,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;EVENTHISTORY_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"` GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` diff --git a/services/eventhistory/pkg/config/defaults/defaultconfig.go b/services/eventhistory/pkg/config/defaults/defaultconfig.go index f8180be7dc..ee085414d8 100644 --- a/services/eventhistory/pkg/config/defaults/defaultconfig.go +++ b/services/eventhistory/pkg/config/defaults/defaultconfig.go @@ -48,16 +48,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.GRPCClientTLS == nil && cfg.Commons != nil { diff --git a/services/eventhistory/pkg/config/log.go b/services/eventhistory/pkg/config/log.go deleted file mode 100644 index 3293bea1a7..0000000000 --- a/services/eventhistory/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;EVENTHISTORY_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;EVENTHISTORY_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;EVENTHISTORY_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;EVENTHISTORY_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/eventhistory/pkg/logging/logging.go b/services/eventhistory/pkg/logging/logging.go deleted file mode 100644 index ce531795e1..0000000000 --- a/services/eventhistory/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/eventhistory/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), - ) -} diff --git a/services/frontend/pkg/command/health.go b/services/frontend/pkg/command/health.go index 43ddd2a93c..efe0e9693d 100644 --- a/services/frontend/pkg/command/health.go +++ b/services/frontend/pkg/command/health.go @@ -6,9 +6,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/frontend/pkg/config" "github.com/opencloud-eu/opencloud/services/frontend/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/frontend/pkg/logging" "github.com/spf13/cobra" ) @@ -22,7 +22,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/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index 547c7c8b22..17da6ff7a2 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/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/frontend/pkg/config" "github.com/opencloud-eu/opencloud/services/frontend/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/frontend/pkg/logging" "github.com/opencloud-eu/opencloud/services/frontend/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/frontend/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/frontend/pkg/config/config.go b/services/frontend/pkg/config/config.go index ece3152f8d..73dc6a6744 100644 --- a/services/frontend/pkg/config/config.go +++ b/services/frontend/pkg/config/config.go @@ -8,10 +8,10 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;FRONTEND_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"` @@ -67,13 +67,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;FRONTEND_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;FRONTEND_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;FRONTEND_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;FRONTEND_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Service struct { Name string `yaml:"-"` } diff --git a/services/frontend/pkg/config/defaults/defaultconfig.go b/services/frontend/pkg/config/defaults/defaultconfig.go index 5faef3bc2f..fb2a958d54 100644 --- a/services/frontend/pkg/config/defaults/defaultconfig.go +++ b/services/frontend/pkg/config/defaults/defaultconfig.go @@ -164,16 +164,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.Reva == nil && cfg.Commons != nil { diff --git a/services/frontend/pkg/logging/logging.go b/services/frontend/pkg/logging/logging.go deleted file mode 100644 index dbd4c7baf8..0000000000 --- a/services/frontend/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/frontend/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), - ) -} diff --git a/services/gateway/pkg/command/health.go b/services/gateway/pkg/command/health.go index 83b35d2ee1..39c7245f7b 100644 --- a/services/gateway/pkg/command/health.go +++ b/services/gateway/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/gateway/pkg/config" "github.com/opencloud-eu/opencloud/services/gateway/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/gateway/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/gateway/pkg/command/server.go b/services/gateway/pkg/command/server.go index 038f881294..e198f8522e 100644 --- a/services/gateway/pkg/command/server.go +++ b/services/gateway/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/gateway/pkg/config" "github.com/opencloud-eu/opencloud/services/gateway/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/gateway/pkg/logging" "github.com/opencloud-eu/opencloud/services/gateway/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/gateway/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/gateway/pkg/config/config.go b/services/gateway/pkg/config/config.go index 4f6a50f15f..4e1ad995e5 100644 --- a/services/gateway/pkg/config/config.go +++ b/services/gateway/pkg/config/config.go @@ -10,9 +10,9 @@ import ( 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"` + Service Service `yaml:"-"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;GATEWAY_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"` @@ -50,13 +50,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;GATEWAY_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;GATEWAY_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;GATEWAY_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;GATEWAY_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Service struct { Name string `yaml:"-"` } diff --git a/services/gateway/pkg/config/defaults/defaultconfig.go b/services/gateway/pkg/config/defaults/defaultconfig.go index c0fc844284..bbe5ddda54 100644 --- a/services/gateway/pkg/config/defaults/defaultconfig.go +++ b/services/gateway/pkg/config/defaults/defaultconfig.go @@ -74,16 +74,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.Reva == nil && cfg.Commons != nil { diff --git a/services/gateway/pkg/logging/logging.go b/services/gateway/pkg/logging/logging.go deleted file mode 100644 index 8095315eb9..0000000000 --- a/services/gateway/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/gateway/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), - ) -} diff --git a/services/graph/pkg/command/health.go b/services/graph/pkg/command/health.go index cac63221b8..9b4ed9fe34 100644 --- a/services/graph/pkg/command/health.go +++ b/services/graph/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/graph/pkg/config" "github.com/opencloud-eu/opencloud/services/graph/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/graph/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/graph/pkg/command/server.go b/services/graph/pkg/command/server.go index fb61fadd70..5d4dadbe17 100644 --- a/services/graph/pkg/command/server.go +++ b/services/graph/pkg/command/server.go @@ -6,12 +6,12 @@ import ( "os/signal" "github.com/opencloud-eu/opencloud/pkg/config/configlog" + "github.com/opencloud-eu/opencloud/pkg/log" "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/graph/pkg/config" "github.com/opencloud-eu/opencloud/services/graph/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/graph/pkg/logging" "github.com/opencloud-eu/opencloud/services/graph/pkg/metrics" "github.com/opencloud-eu/opencloud/services/graph/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/graph/pkg/server/http" @@ -31,7 +31,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/graph/pkg/config/config.go b/services/graph/pkg/config/config.go index 6386025a84..51571c4607 100644 --- a/services/graph/pkg/config/config.go +++ b/services/graph/pkg/config/config.go @@ -13,9 +13,9 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Cache *Cache `yaml:"cache"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;GRAPH_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Cache *Cache `yaml:"cache"` + Debug Debug `yaml:"debug"` HTTP HTTP `yaml:"http"` diff --git a/services/graph/pkg/config/defaults/defaultconfig.go b/services/graph/pkg/config/defaults/defaultconfig.go index 0a97411a82..9b5352f6ea 100644 --- a/services/graph/pkg/config/defaults/defaultconfig.go +++ b/services/graph/pkg/config/defaults/defaultconfig.go @@ -140,16 +140,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.Cache == nil && cfg.Commons != nil && cfg.Commons.Cache != nil { diff --git a/services/graph/pkg/config/log.go b/services/graph/pkg/config/log.go deleted file mode 100644 index fa1624c4a4..0000000000 --- a/services/graph/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;GRAPH_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;GRAPH_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;GRAPH_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;GRAPH_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/graph/pkg/logging/logging.go b/services/graph/pkg/logging/logging.go deleted file mode 100644 index f957e44c6e..0000000000 --- a/services/graph/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/graph/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), - ) -} diff --git a/services/groups/pkg/command/health.go b/services/groups/pkg/command/health.go index 250309c204..60eb7fd8b9 100644 --- a/services/groups/pkg/command/health.go +++ b/services/groups/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/groups/pkg/config" "github.com/opencloud-eu/opencloud/services/groups/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/groups/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/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index 053f3d5a9b..efbbd03c04 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -7,13 +7,13 @@ import ( "github.com/opencloud-eu/opencloud/pkg/config/configlog" "github.com/opencloud-eu/opencloud/pkg/ldap" + "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/groups/pkg/config" "github.com/opencloud-eu/opencloud/services/groups/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/groups/pkg/logging" "github.com/opencloud-eu/opencloud/services/groups/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/groups/pkg/server/debug" "github.com/opencloud-eu/reva/v2/cmd/revad/runtime" @@ -30,7 +30,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/groups/pkg/config/config.go b/services/groups/pkg/config/config.go index ae7f59b75f..47bf20e02b 100644 --- a/services/groups/pkg/config/config.go +++ b/services/groups/pkg/config/config.go @@ -7,10 +7,10 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;GROUPS_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"` @@ -25,13 +25,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;GROUPS_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;GROUPS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;GROUPS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;GROUPS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Service struct { Name string `yaml:"-"` } diff --git a/services/groups/pkg/config/defaults/defaultconfig.go b/services/groups/pkg/config/defaults/defaultconfig.go index 568addf4cb..f723079489 100644 --- a/services/groups/pkg/config/defaults/defaultconfig.go +++ b/services/groups/pkg/config/defaults/defaultconfig.go @@ -84,16 +84,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.Reva == nil && cfg.Commons != nil { diff --git a/services/groups/pkg/logging/logging.go b/services/groups/pkg/logging/logging.go deleted file mode 100644 index aec0df9935..0000000000 --- a/services/groups/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/groups/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), - ) -} diff --git a/services/idm/pkg/command/health.go b/services/idm/pkg/command/health.go index 050dd35e24..31d0ab6a44 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 1f31065cdb..b172c403b7 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 a71991563e..1d2ddbf092 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 173c6f4803..13e61d7683 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 `yaml:"loglevel" 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 0bf7b8afb1..225cd93576 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 ebcd31aa5d..0000000000 --- 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 e989ed807c..0000000000 --- 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), - ) -} diff --git a/services/idp/pkg/command/health.go b/services/idp/pkg/command/health.go index 2cb1f6f49c..ff189359a8 100644 --- a/services/idp/pkg/command/health.go +++ b/services/idp/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/idp/pkg/config" "github.com/opencloud-eu/opencloud/services/idp/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/idp/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/idp/pkg/command/server.go b/services/idp/pkg/command/server.go index 6cc97b8e25..fa08d9eaec 100644 --- a/services/idp/pkg/command/server.go +++ b/services/idp/pkg/command/server.go @@ -16,12 +16,12 @@ import ( "path/filepath" "github.com/opencloud-eu/opencloud/pkg/config/configlog" + "github.com/opencloud-eu/opencloud/pkg/log" "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/idp/pkg/config" "github.com/opencloud-eu/opencloud/services/idp/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/idp/pkg/logging" "github.com/opencloud-eu/opencloud/services/idp/pkg/metrics" "github.com/opencloud-eu/opencloud/services/idp/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/idp/pkg/server/http" @@ -53,7 +53,7 @@ func Server(cfg *config.Config) *cobra.Command { return nil }, 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/idp/pkg/config/config.go b/services/idp/pkg/config/config.go index 31a02deb83..627bba64db 100644 --- a/services/idp/pkg/config/config.go +++ b/services/idp/pkg/config/config.go @@ -13,8 +13,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;IDP_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 HTTP `yaml:"http"` diff --git a/services/idp/pkg/config/defaults/defaultconfig.go b/services/idp/pkg/config/defaults/defaultconfig.go index 09c07d957d..356f71e7dd 100644 --- a/services/idp/pkg/config/defaults/defaultconfig.go +++ b/services/idp/pkg/config/defaults/defaultconfig.go @@ -138,16 +138,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.Reva == nil && cfg.Commons != nil { diff --git a/services/idp/pkg/config/log.go b/services/idp/pkg/config/log.go deleted file mode 100644 index 5819a2c8ad..0000000000 --- a/services/idp/pkg/config/log.go +++ /dev/null @@ -1,9 +0,0 @@ -package config - -// Log defines the available log configuration. -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;IDP_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;IDP_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;IDP_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;IDP_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/idp/pkg/logging/logging.go b/services/idp/pkg/logging/logging.go deleted file mode 100644 index 44172d88c2..0000000000 --- a/services/idp/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/idp/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), - ) -} diff --git a/services/invitations/pkg/command/health.go b/services/invitations/pkg/command/health.go index 05fddacdb9..ce498f5509 100644 --- a/services/invitations/pkg/command/health.go +++ b/services/invitations/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/invitations/pkg/config" "github.com/opencloud-eu/opencloud/services/invitations/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/invitations/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/invitations/pkg/command/server.go b/services/invitations/pkg/command/server.go index be6644c55d..23cf31690e 100644 --- a/services/invitations/pkg/command/server.go +++ b/services/invitations/pkg/command/server.go @@ -6,12 +6,12 @@ import ( "os/signal" "github.com/opencloud-eu/opencloud/pkg/config/configlog" + "github.com/opencloud-eu/opencloud/pkg/log" "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/invitations/pkg/config" "github.com/opencloud-eu/opencloud/services/invitations/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/invitations/pkg/logging" "github.com/opencloud-eu/opencloud/services/invitations/pkg/metrics" "github.com/opencloud-eu/opencloud/services/invitations/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/invitations/pkg/server/http" @@ -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/invitations/pkg/config/config.go b/services/invitations/pkg/config/config.go index b3b363f10a..6cf9843d59 100644 --- a/services/invitations/pkg/config/config.go +++ b/services/invitations/pkg/config/config.go @@ -12,8 +12,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;INVITATIONS_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 HTTP `yaml:"http"` diff --git a/services/invitations/pkg/config/defaults/defaultconfig.go b/services/invitations/pkg/config/defaults/defaultconfig.go index 664815e3d1..efa629e25c 100644 --- a/services/invitations/pkg/config/defaults/defaultconfig.go +++ b/services/invitations/pkg/config/defaults/defaultconfig.go @@ -43,16 +43,8 @@ func DefaultConfig() *config.Config { } 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.Commons != nil { diff --git a/services/invitations/pkg/config/log.go b/services/invitations/pkg/config/log.go deleted file mode 100644 index 47844f1dc9..0000000000 --- a/services/invitations/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;INVITATIONS_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;INVITATIONS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;INVITATIONS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;INVITATIONS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/invitations/pkg/logging/logging.go b/services/invitations/pkg/logging/logging.go deleted file mode 100644 index f58d014aaa..0000000000 --- a/services/invitations/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/invitations/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), - ) -} diff --git a/services/nats/pkg/command/server.go b/services/nats/pkg/command/server.go index 3bf9169389..342036167e 100644 --- a/services/nats/pkg/command/server.go +++ b/services/nats/pkg/command/server.go @@ -8,6 +8,7 @@ import ( "github.com/opencloud-eu/opencloud/pkg/config/configlog" pkgcrypto "github.com/opencloud-eu/opencloud/pkg/crypto" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/pkg/runner" "github.com/opencloud-eu/opencloud/services/nats/pkg/config" "github.com/opencloud-eu/opencloud/services/nats/pkg/config/parser" @@ -27,7 +28,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) var cancel context.CancelFunc if cfg.Context == nil { diff --git a/services/nats/pkg/config/config.go b/services/nats/pkg/config/config.go index 3f4cb34eb1..214b09ab64 100644 --- a/services/nats/pkg/config/config.go +++ b/services/nats/pkg/config/config.go @@ -8,10 +8,10 @@ import ( // Config combines all available configuration parts. 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:"loglevel" env:"OC_LOG_LEVEL;NATS_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` Nats Nats `ociConfig:"nats"` diff --git a/services/nats/pkg/config/defaults/defaultconfig.go b/services/nats/pkg/config/defaults/defaultconfig.go index 05a2f4e341..52dcfda07f 100644 --- a/services/nats/pkg/config/defaults/defaultconfig.go +++ b/services/nats/pkg/config/defaults/defaultconfig.go @@ -44,18 +44,9 @@ 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" } - } // Sanitize sanitizes the configuration diff --git a/services/nats/pkg/config/log.go b/services/nats/pkg/config/log.go deleted file mode 100644 index 1b0340b72b..0000000000 --- a/services/nats/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;NATS_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;NATS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;NATS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;NATS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/nats/pkg/logging/logging.go b/services/nats/pkg/logging/logging.go deleted file mode 100644 index e3b93418b9..0000000000 --- a/services/nats/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/nats/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), - ) -} diff --git a/services/notifications/pkg/command/server.go b/services/notifications/pkg/command/server.go index 7c2896abed..e512286a6a 100644 --- a/services/notifications/pkg/command/server.go +++ b/services/notifications/pkg/command/server.go @@ -8,6 +8,7 @@ import ( "github.com/opencloud-eu/opencloud/pkg/config/configlog" "github.com/opencloud-eu/opencloud/pkg/generators" + "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/service/grpc" @@ -16,7 +17,6 @@ import ( "github.com/opencloud-eu/opencloud/services/notifications/pkg/channels" "github.com/opencloud-eu/opencloud/services/notifications/pkg/config" "github.com/opencloud-eu/opencloud/services/notifications/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/notifications/pkg/logging" "github.com/opencloud-eu/opencloud/services/notifications/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/notifications/pkg/service" "github.com/opencloud-eu/reva/v2/pkg/events" @@ -38,7 +38,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 { diff --git a/services/notifications/pkg/config/config.go b/services/notifications/pkg/config/config.go index afc8253847..5206eae5ff 100644 --- a/services/notifications/pkg/config/config.go +++ b/services/notifications/pkg/config/config.go @@ -14,8 +14,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;NOTIFICATIONS_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` WebUIURL string `yaml:"opencloud_url" env:"OC_URL;NOTIFICATIONS_WEB_UI_URL" desc:"The public facing URL of the OpenCloud Web UI, used e.g. when sending notification eMails" introductionVersion:"1.0.0"` diff --git a/services/notifications/pkg/config/defaults/defaultconfig.go b/services/notifications/pkg/config/defaults/defaultconfig.go index 3e2a07b54a..bc49caa141 100644 --- a/services/notifications/pkg/config/defaults/defaultconfig.go +++ b/services/notifications/pkg/config/defaults/defaultconfig.go @@ -54,16 +54,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.Notifications.GRPCClientTLS == nil && cfg.Commons != nil { diff --git a/services/notifications/pkg/config/log.go b/services/notifications/pkg/config/log.go deleted file mode 100644 index 4dcffea9c7..0000000000 --- a/services/notifications/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;NOTIFICATIONS_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;NOTIFICATIONS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;NOTIFICATIONS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;NOTIFICATIONS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/notifications/pkg/config/parser/parse.go b/services/notifications/pkg/config/parser/parse.go index 57e78886c7..33df96694c 100644 --- a/services/notifications/pkg/config/parser/parse.go +++ b/services/notifications/pkg/config/parser/parse.go @@ -7,12 +7,11 @@ import ( "strings" occfg "github.com/opencloud-eu/opencloud/pkg/config" + "github.com/opencloud-eu/opencloud/pkg/config/envdecode" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/pkg/shared" "github.com/opencloud-eu/opencloud/services/notifications/pkg/config" "github.com/opencloud-eu/opencloud/services/notifications/pkg/config/defaults" - "github.com/opencloud-eu/opencloud/services/notifications/pkg/logging" - - "github.com/opencloud-eu/opencloud/pkg/config/envdecode" ) // ParseConfig loads configuration from known paths. @@ -38,7 +37,7 @@ func ParseConfig(cfg *config.Config) error { } func Validate(cfg *config.Config) error { - logger := logging.Configure(cfg.Service.Name, cfg.Log) + logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel) if cfg.Notifications.SMTP.Host != "" { switch cfg.Notifications.SMTP.Encryption { diff --git a/services/notifications/pkg/logging/logging.go b/services/notifications/pkg/logging/logging.go deleted file mode 100644 index 1c33af7700..0000000000 --- a/services/notifications/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/notifications/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), - ) -} 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), - ) -} diff --git a/services/ocs/pkg/command/health.go b/services/ocs/pkg/command/health.go index 297204d88e..487b7e5292 100644 --- a/services/ocs/pkg/command/health.go +++ b/services/ocs/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/ocs/pkg/config" "github.com/opencloud-eu/opencloud/services/ocs/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/ocs/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/ocs/pkg/command/server.go b/services/ocs/pkg/command/server.go index a28cef5b59..87048b29a7 100644 --- a/services/ocs/pkg/command/server.go +++ b/services/ocs/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/runner" ogrpc "github.com/opencloud-eu/opencloud/pkg/service/grpc" "github.com/opencloud-eu/opencloud/pkg/tracing" "github.com/opencloud-eu/opencloud/pkg/version" "github.com/opencloud-eu/opencloud/services/ocs/pkg/config" "github.com/opencloud-eu/opencloud/services/ocs/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/ocs/pkg/logging" "github.com/opencloud-eu/opencloud/services/ocs/pkg/metrics" "github.com/opencloud-eu/opencloud/services/ocs/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/ocs/pkg/server/http" @@ -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/ocs/pkg/config/config.go b/services/ocs/pkg/config/config.go index 46c4e440b5..bbfbe587e3 100644 --- a/services/ocs/pkg/config/config.go +++ b/services/ocs/pkg/config/config.go @@ -14,8 +14,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;OCS_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 HTTP `yaml:"http"` diff --git a/services/ocs/pkg/config/defaults/defaultconfig.go b/services/ocs/pkg/config/defaults/defaultconfig.go index 1b0a7d55ce..59872940c8 100644 --- a/services/ocs/pkg/config/defaults/defaultconfig.go +++ b/services/ocs/pkg/config/defaults/defaultconfig.go @@ -49,16 +49,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.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/ocs/pkg/config/log.go b/services/ocs/pkg/config/log.go deleted file mode 100644 index 0b6dd980f8..0000000000 --- a/services/ocs/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;OCS_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;OCS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;OCS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;OCS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/ocs/pkg/logging/logging.go b/services/ocs/pkg/logging/logging.go deleted file mode 100644 index f6970a2a83..0000000000 --- a/services/ocs/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/ocs/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), - ) -} diff --git a/services/policies/pkg/command/health.go b/services/policies/pkg/command/health.go index 15d18fa3e5..223b074be9 100644 --- a/services/policies/pkg/command/health.go +++ b/services/policies/pkg/command/health.go @@ -21,13 +21,7 @@ func Health(cfg *config.Config) *cobra.Command { return configlog.ReturnError(parser.ParseConfig(cfg)) }, RunE: func(cmd *cobra.Command, args []string) error { - logger := log.NewLogger( - log.Name(cfg.Service.Name), - log.Level(cfg.Log.Level), - log.Pretty(cfg.Log.Pretty), - log.Color(cfg.Log.Color), - log.File(cfg.Log.File), - ) + logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel) resp, err := http.Get( fmt.Sprintf( diff --git a/services/policies/pkg/command/server.go b/services/policies/pkg/command/server.go index 1d807a2adb..92802e34cb 100644 --- a/services/policies/pkg/command/server.go +++ b/services/policies/pkg/command/server.go @@ -40,13 +40,7 @@ func Server(cfg *config.Config) *cobra.Command { } ctx := cfg.Context - logger := log.NewLogger( - log.Name(cfg.Service.Name), - log.Level(cfg.Log.Level), - log.Pretty(cfg.Log.Pretty), - log.Color(cfg.Log.Color), - log.File(cfg.Log.File), - ).SubloggerWithRequestID(ctx) + logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel).SubloggerWithRequestID(ctx) traceProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name) if err != nil { diff --git a/services/policies/pkg/config/config.go b/services/policies/pkg/config/config.go index 15d3112280..51bee34cb2 100644 --- a/services/policies/pkg/config/config.go +++ b/services/policies/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { Events Events `yaml:"events"` GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` Context context.Context `yaml:"-"` - Log *Log `yaml:"log"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;POLICIES_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` Engine Engine `yaml:"engine"` Postprocessing Postprocessing `yaml:"postprocessing"` } @@ -57,14 +57,6 @@ type Events struct { AuthPassword string `yaml:"password" env:"OC_EVENTS_AUTH_PASSWORD;POLICIES_EVENTS_AUTH_PASSWORD" desc:"The password to authenticate with the events broker. The events broker is the OpenCloud service which receives and delivers events between the services." introductionVersion:"1.0.0"` } -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OC_LOG_LEVEL;POLICIES_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;POLICIES_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;POLICIES_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;POLICIES_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - // Debug defines the available debug configuration. type Debug struct { Addr string `yaml:"addr" env:"POLICIES_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed." introductionVersion:"1.0.0"` diff --git a/services/policies/pkg/config/defaults/defaultconfig.go b/services/policies/pkg/config/defaults/defaultconfig.go index 2791396eb1..45ff341852 100644 --- a/services/policies/pkg/config/defaults/defaultconfig.go +++ b/services/policies/pkg/config/defaults/defaultconfig.go @@ -43,15 +43,8 @@ func DefaultConfig() *config.Config { } func EnsureDefaults(cfg *config.Config) { - 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/postprocessing/pkg/command/server.go b/services/postprocessing/pkg/command/server.go index 575bc40cf4..c80e00f9f2 100644 --- a/services/postprocessing/pkg/command/server.go +++ b/services/postprocessing/pkg/command/server.go @@ -6,11 +6,11 @@ import ( "os" "os/signal" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/pkg/runner" "github.com/opencloud-eu/opencloud/pkg/tracing" "github.com/opencloud-eu/opencloud/services/postprocessing/pkg/config" "github.com/opencloud-eu/opencloud/services/postprocessing/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/postprocessing/pkg/logging" "github.com/opencloud-eu/opencloud/services/postprocessing/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/postprocessing/pkg/service" "github.com/opencloud-eu/reva/v2/pkg/store" @@ -33,7 +33,7 @@ func Server(cfg *config.Config) *cobra.Command { return err }, 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) var cancel context.CancelFunc if cfg.Context == nil { diff --git a/services/postprocessing/pkg/config/config.go b/services/postprocessing/pkg/config/config.go index d651d602a4..858f6e5148 100644 --- a/services/postprocessing/pkg/config/config.go +++ b/services/postprocessing/pkg/config/config.go @@ -13,8 +13,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;POSTPROCESSING_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` Store Store `yaml:"store"` Postprocessing Postprocessing `yaml:"postprocessing"` diff --git a/services/postprocessing/pkg/config/defaults/defaultconfig.go b/services/postprocessing/pkg/config/defaults/defaultconfig.go index 09305ba7c9..39186aaa1f 100644 --- a/services/postprocessing/pkg/config/defaults/defaultconfig.go +++ b/services/postprocessing/pkg/config/defaults/defaultconfig.go @@ -48,18 +48,9 @@ func DefaultConfig() *config.Config { // EnsureDefaults ensures defaults on a config func EnsureDefaults(cfg *config.Config) { - // provide with defaults for shared logging, since we need a valid destination address for BindEnv. - 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" } - } // Sanitize does nothing atm diff --git a/services/postprocessing/pkg/config/log.go b/services/postprocessing/pkg/config/log.go deleted file mode 100644 index 1066e805f1..0000000000 --- a/services/postprocessing/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;POSTPROCESSING_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;POSTPROCESSING_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;POSTPROCESSING_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;POSTPROCESSING_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/postprocessing/pkg/logging/logging.go b/services/postprocessing/pkg/logging/logging.go deleted file mode 100644 index 98468ab7e8..0000000000 --- a/services/postprocessing/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/postprocessing/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), - ) -} diff --git a/services/proxy/pkg/command/health.go b/services/proxy/pkg/command/health.go index d3952f653a..564335f6d6 100644 --- a/services/proxy/pkg/command/health.go +++ b/services/proxy/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/proxy/pkg/config" "github.com/opencloud-eu/opencloud/services/proxy/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/proxy/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/proxy/pkg/command/server.go b/services/proxy/pkg/command/server.go index 418dfc0e49..25c1d045dc 100644 --- a/services/proxy/pkg/command/server.go +++ b/services/proxy/pkg/command/server.go @@ -24,7 +24,6 @@ import ( settingssvc "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/services/settings/v0" "github.com/opencloud-eu/opencloud/services/proxy/pkg/config" "github.com/opencloud-eu/opencloud/services/proxy/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/proxy/pkg/logging" "github.com/opencloud-eu/opencloud/services/proxy/pkg/metrics" "github.com/opencloud-eu/opencloud/services/proxy/pkg/middleware" "github.com/opencloud-eu/opencloud/services/proxy/pkg/proxy" @@ -76,7 +75,7 @@ func Server(cfg *config.Config) *cobra.Command { store.Authentication(cfg.PreSignedURL.SigningKeys.AuthUsername, cfg.PreSignedURL.SigningKeys.AuthPassword), ) - 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/proxy/pkg/config/config.go b/services/proxy/pkg/config/config.go index 37143132b1..3e0ec93084 100644 --- a/services/proxy/pkg/config/config.go +++ b/services/proxy/pkg/config/config.go @@ -14,8 +14,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug" mask:"struct"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;PROXY_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug" mask:"struct"` HTTP HTTP `yaml:"http"` diff --git a/services/proxy/pkg/config/defaults/defaultconfig.go b/services/proxy/pkg/config/defaults/defaultconfig.go index 195d0bed78..187e52be6f 100644 --- a/services/proxy/pkg/config/defaults/defaultconfig.go +++ b/services/proxy/pkg/config/defaults/defaultconfig.go @@ -298,16 +298,8 @@ func DefaultPolicies() []config.Policy { // 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.OIDC.UserinfoCache == nil && cfg.Commons != nil && cfg.Commons.Cache != nil { diff --git a/services/proxy/pkg/config/log.go b/services/proxy/pkg/config/log.go deleted file mode 100644 index fdaeaed439..0000000000 --- a/services/proxy/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;PROXY_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;PROXY_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;PROXY_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;PROXY_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/proxy/pkg/logging/logging.go b/services/proxy/pkg/logging/logging.go deleted file mode 100644 index 79d37447d4..0000000000 --- a/services/proxy/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/proxy/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), - ) -} diff --git a/services/proxy/pkg/proxy/proxy_integration_test.go b/services/proxy/pkg/proxy/proxy_integration_test.go index ea32170e04..ace5543a59 100644 --- a/services/proxy/pkg/proxy/proxy_integration_test.go +++ b/services/proxy/pkg/proxy/proxy_integration_test.go @@ -221,7 +221,6 @@ func (tc *testCase) expectProxyTo(strURL string) testCase { func testConfig(policy []config.Policy) *config.Config { return &config.Config{ - Log: &config.Log{}, Debug: config.Debug{}, HTTP: config.HTTP{}, Policies: policy, diff --git a/services/search/pkg/command/health.go b/services/search/pkg/command/health.go index d3c6d40706..60412aab9b 100644 --- a/services/search/pkg/command/health.go +++ b/services/search/pkg/command/health.go @@ -4,9 +4,9 @@ import ( "fmt" "net/http" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/services/search/pkg/config" "github.com/opencloud-eu/opencloud/services/search/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/search/pkg/logging" "github.com/spf13/cobra" ) @@ -20,7 +20,7 @@ func Health(cfg *config.Config) *cobra.Command { return 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/search/pkg/command/server.go b/services/search/pkg/command/server.go index 67f3987457..e7378079d7 100644 --- a/services/search/pkg/command/server.go +++ b/services/search/pkg/command/server.go @@ -10,6 +10,7 @@ import ( "github.com/opencloud-eu/opencloud/pkg/config/configlog" "github.com/opencloud-eu/opencloud/pkg/generators" + "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" @@ -19,7 +20,6 @@ import ( "github.com/opencloud-eu/opencloud/services/search/pkg/config" "github.com/opencloud-eu/opencloud/services/search/pkg/config/parser" "github.com/opencloud-eu/opencloud/services/search/pkg/content" - "github.com/opencloud-eu/opencloud/services/search/pkg/logging" "github.com/opencloud-eu/opencloud/services/search/pkg/metrics" "github.com/opencloud-eu/opencloud/services/search/pkg/opensearch" bleveQuery "github.com/opencloud-eu/opencloud/services/search/pkg/query/bleve" @@ -44,7 +44,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/search/pkg/config/config.go b/services/search/pkg/config/config.go index 0ea50423df..128061b76f 100644 --- a/services/search/pkg/config/config.go +++ b/services/search/pkg/config/config.go @@ -13,8 +13,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;SEARCH_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"` GrpcClient client.Client `yaml:"-"` diff --git a/services/search/pkg/config/defaults/defaultconfig.go b/services/search/pkg/config/defaults/defaultconfig.go index d55702f35c..630cd24e7e 100644 --- a/services/search/pkg/config/defaults/defaultconfig.go +++ b/services/search/pkg/config/defaults/defaultconfig.go @@ -70,16 +70,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.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/search/pkg/config/log.go b/services/search/pkg/config/log.go deleted file mode 100644 index b191960f57..0000000000 --- a/services/search/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;SEARCH_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;SEARCH_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;SEARCH_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;SEARCH_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/search/pkg/logging/logging.go b/services/search/pkg/logging/logging.go deleted file mode 100644 index 3627d12280..0000000000 --- a/services/search/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/search/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), - ) -} diff --git a/services/settings/pkg/command/health.go b/services/settings/pkg/command/health.go index be648868b2..ab39debae5 100644 --- a/services/settings/pkg/command/health.go +++ b/services/settings/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/settings/pkg/config" "github.com/opencloud-eu/opencloud/services/settings/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/settings/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/settings/pkg/command/server.go b/services/settings/pkg/command/server.go index dc889f053f..3a81994b0d 100644 --- a/services/settings/pkg/command/server.go +++ b/services/settings/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/runner" ogrpc "github.com/opencloud-eu/opencloud/pkg/service/grpc" "github.com/opencloud-eu/opencloud/pkg/tracing" "github.com/opencloud-eu/opencloud/pkg/version" "github.com/opencloud-eu/opencloud/services/settings/pkg/config" "github.com/opencloud-eu/opencloud/services/settings/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/settings/pkg/logging" "github.com/opencloud-eu/opencloud/services/settings/pkg/metrics" "github.com/opencloud-eu/opencloud/services/settings/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/settings/pkg/server/grpc" @@ -31,7 +31,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/settings/pkg/config/config.go b/services/settings/pkg/config/config.go index 17305a390a..d4ba71e3c4 100644 --- a/services/settings/pkg/config/config.go +++ b/services/settings/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;SETTINGS_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 HTTP `yaml:"http"` GRPC GRPCConfig `yaml:"grpc"` diff --git a/services/settings/pkg/config/defaults/defaultconfig.go b/services/settings/pkg/config/defaults/defaultconfig.go index b2c1df408e..d881be54db 100644 --- a/services/settings/pkg/config/defaults/defaultconfig.go +++ b/services/settings/pkg/config/defaults/defaultconfig.go @@ -69,16 +69,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.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/settings/pkg/config/log.go b/services/settings/pkg/config/log.go deleted file mode 100644 index 458470484c..0000000000 --- a/services/settings/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;SETTINGS_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;SETTINGS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;SETTINGS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;SETTINGS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/settings/pkg/logging/logging.go b/services/settings/pkg/logging/logging.go deleted file mode 100644 index 0bb0210bff..0000000000 --- a/services/settings/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/settings/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), - ) -} diff --git a/services/settings/pkg/store/metadata/store.go b/services/settings/pkg/store/metadata/store.go index b5684b3773..c15b327020 100644 --- a/services/settings/pkg/store/metadata/store.go +++ b/services/settings/pkg/store/metadata/store.go @@ -74,14 +74,9 @@ func (s *Store) Init() { // New creates a new store func New(cfg *config.Config) settings.Manager { s := Store{ - Logger: olog.NewLogger( - olog.Color(cfg.Log.Color), - olog.Pretty(cfg.Log.Pretty), - olog.Level(cfg.Log.Level), - olog.File(cfg.Log.File), - ), - cfg: cfg, - l: &sync.Mutex{}, + Logger: olog.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel), + cfg: cfg, + l: &sync.Mutex{}, } return &s diff --git a/services/sharing/pkg/command/health.go b/services/sharing/pkg/command/health.go index 3bbcc0cdbd..d2a796bf18 100644 --- a/services/sharing/pkg/command/health.go +++ b/services/sharing/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/sharing/pkg/config" "github.com/opencloud-eu/opencloud/services/sharing/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/sharing/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/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index 14b2b17e56..5ac54ecfe2 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -8,13 +8,13 @@ import ( "path/filepath" "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/sharing/pkg/config" "github.com/opencloud-eu/opencloud/services/sharing/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/sharing/pkg/logging" "github.com/opencloud-eu/opencloud/services/sharing/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/sharing/pkg/server/debug" "github.com/opencloud-eu/reva/v2/cmd/revad/runtime" @@ -31,7 +31,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/sharing/pkg/config/config.go b/services/sharing/pkg/config/config.go index db279b98a6..0ba4a330fc 100644 --- a/services/sharing/pkg/config/config.go +++ b/services/sharing/pkg/config/config.go @@ -7,10 +7,10 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;SHARING_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"` @@ -32,13 +32,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;SHARING_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;SHARING_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;SHARING_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;SHARING_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Service struct { Name string `yaml:"-"` } diff --git a/services/sharing/pkg/config/defaults/defaultconfig.go b/services/sharing/pkg/config/defaults/defaultconfig.go index cce41eae9c..bf9432716d 100644 --- a/services/sharing/pkg/config/defaults/defaultconfig.go +++ b/services/sharing/pkg/config/defaults/defaultconfig.go @@ -90,15 +90,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.Reva == nil && cfg.Commons != nil { diff --git a/services/sharing/pkg/logging/logging.go b/services/sharing/pkg/logging/logging.go deleted file mode 100644 index 91eafadec0..0000000000 --- a/services/sharing/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/sharing/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), - ) -} diff --git a/services/sse/pkg/command/health.go b/services/sse/pkg/command/health.go index 0eafc3e406..82d9444bc8 100644 --- a/services/sse/pkg/command/health.go +++ b/services/sse/pkg/command/health.go @@ -21,13 +21,7 @@ func Health(cfg *config.Config) *cobra.Command { return configlog.ReturnError(parser.ParseConfig(cfg)) }, RunE: func(cmd *cobra.Command, args []string) error { - logger := log.NewLogger( - log.Name(cfg.Service.Name), - log.Level(cfg.Log.Level), - log.Pretty(cfg.Log.Pretty), - log.Color(cfg.Log.Color), - log.File(cfg.Log.File), - ) + logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel) resp, err := http.Get( fmt.Sprintf( diff --git a/services/sse/pkg/command/server.go b/services/sse/pkg/command/server.go index feef04961c..1dd0705f3a 100644 --- a/services/sse/pkg/command/server.go +++ b/services/sse/pkg/command/server.go @@ -41,13 +41,7 @@ func Server(cfg *config.Config) *cobra.Command { } ctx := cfg.Context - logger := log.NewLogger( - log.Name(cfg.Service.Name), - log.Level(cfg.Log.Level), - log.Pretty(cfg.Log.Pretty), - log.Color(cfg.Log.Color), - log.File(cfg.Log.File), - ) + logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel) tracerProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name) if err != nil { diff --git a/services/sse/pkg/config/config.go b/services/sse/pkg/config/config.go index a2948f588b..0f7c46694d 100644 --- a/services/sse/pkg/config/config.go +++ b/services/sse/pkg/config/config.go @@ -9,10 +9,9 @@ import ( // Config combines all available configuration parts. type Config struct { - Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service - Log *Log - - Debug Debug `mask:"struct" yaml:"debug"` + Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;SSE_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `mask:"struct" yaml:"debug"` Service Service `yaml:"-"` KeepAliveInterval time.Duration `yaml:"keepalive_interval" env:"SSE_KEEPALIVE_INTERVAL" desc:"To prevent intermediate proxies from closing the SSE connection, send periodic SSE comments to keep it open." introductionVersion:"1.0.0"` @@ -29,14 +28,6 @@ type Service struct { Name string `yaml:"-"` } -// Log defines the available log configuration. -type Log struct { - Level string `mapstructure:"level" env:"OC_LOG_LEVEL;SSE_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;SSE_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;SSE_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;SSE_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - // Debug defines the available debug configuration. type Debug struct { Addr string `yaml:"addr" env:"SSE_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed." introductionVersion:"1.0.0"` diff --git a/services/sse/pkg/config/defaults/defaultconfig.go b/services/sse/pkg/config/defaults/defaultconfig.go index 8ea79910f6..30e2854ef9 100644 --- a/services/sse/pkg/config/defaults/defaultconfig.go +++ b/services/sse/pkg/config/defaults/defaultconfig.go @@ -44,16 +44,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.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/storage-publiclink/pkg/command/health.go b/services/storage-publiclink/pkg/command/health.go index 9ba9bacbdb..926532821a 100644 --- a/services/storage-publiclink/pkg/command/health.go +++ b/services/storage-publiclink/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/storage-publiclink/pkg/config" "github.com/opencloud-eu/opencloud/services/storage-publiclink/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/storage-publiclink/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/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index 12d417c765..36fb117ef1 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/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/storage-publiclink/pkg/config" "github.com/opencloud-eu/opencloud/services/storage-publiclink/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/storage-publiclink/pkg/logging" "github.com/opencloud-eu/opencloud/services/storage-publiclink/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/storage-publiclink/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/storage-publiclink/pkg/config/config.go b/services/storage-publiclink/pkg/config/config.go index c0728bc0d0..26566fb089 100644 --- a/services/storage-publiclink/pkg/config/config.go +++ b/services/storage-publiclink/pkg/config/config.go @@ -7,10 +7,10 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;STORAGE_PUBLICLINK_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"` @@ -24,13 +24,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;STORAGE_PUBLICLINK_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;STORAGE_PUBLICLINK_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;STORAGE_PUBLICLINK_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;STORAGE_PUBLICLINK_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - type Service struct { Name string `yaml:"-"` } diff --git a/services/storage-publiclink/pkg/config/defaults/defaultconfig.go b/services/storage-publiclink/pkg/config/defaults/defaultconfig.go index 33f01baf1e..b46cc89dd5 100644 --- a/services/storage-publiclink/pkg/config/defaults/defaultconfig.go +++ b/services/storage-publiclink/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.Reva == nil && cfg.Commons != nil { diff --git a/services/storage-publiclink/pkg/logging/logging.go b/services/storage-publiclink/pkg/logging/logging.go deleted file mode 100644 index bee62d5aaa..0000000000 --- a/services/storage-publiclink/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/storage-publiclink/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), - ) -} diff --git a/services/storage-shares/pkg/command/health.go b/services/storage-shares/pkg/command/health.go index cec693d011..2c745862fc 100644 --- a/services/storage-shares/pkg/command/health.go +++ b/services/storage-shares/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/storage-shares/pkg/config" "github.com/opencloud-eu/opencloud/services/storage-shares/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/storage-shares/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/storage-shares/pkg/command/server.go b/services/storage-shares/pkg/command/server.go index b53c1f48e3..c1e1fa7ee9 100644 --- a/services/storage-shares/pkg/command/server.go +++ b/services/storage-shares/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/storage-shares/pkg/config" "github.com/opencloud-eu/opencloud/services/storage-shares/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/storage-shares/pkg/logging" "github.com/opencloud-eu/opencloud/services/storage-shares/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/storage-shares/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/storage-shares/pkg/config/config.go b/services/storage-shares/pkg/config/config.go index 531a3752eb..c51e185643 100644 --- a/services/storage-shares/pkg/config/config.go +++ b/services/storage-shares/pkg/config/config.go @@ -7,10 +7,10 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;STORAGE_SHARES_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"` @@ -25,12 +25,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;STORAGE_SHARES_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;STORAGE_SHARES_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;STORAGE_SHARES_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;STORAGE_SHARES_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} type Service struct { Name string `yaml:"-"` diff --git a/services/storage-shares/pkg/config/defaults/defaultconfig.go b/services/storage-shares/pkg/config/defaults/defaultconfig.go index 28e2edcac7..14489449ab 100644 --- a/services/storage-shares/pkg/config/defaults/defaultconfig.go +++ b/services/storage-shares/pkg/config/defaults/defaultconfig.go @@ -40,18 +40,9 @@ 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.Reva == nil && cfg.Commons != nil { cfg.Reva = structs.CopyOrZeroValue(cfg.Commons.Reva) } diff --git a/services/storage-shares/pkg/logging/logging.go b/services/storage-shares/pkg/logging/logging.go deleted file mode 100644 index 4b0db494ca..0000000000 --- a/services/storage-shares/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/storage-shares/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), - ) -} diff --git a/services/storage-system/pkg/command/health.go b/services/storage-system/pkg/command/health.go index 79d9659984..291ea8dd39 100644 --- a/services/storage-system/pkg/command/health.go +++ b/services/storage-system/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/storage-system/pkg/config" "github.com/opencloud-eu/opencloud/services/storage-system/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/storage-system/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/storage-system/pkg/command/server.go b/services/storage-system/pkg/command/server.go index b69315e3cd..382cd2d0e1 100644 --- a/services/storage-system/pkg/command/server.go +++ b/services/storage-system/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/storage-system/pkg/config" "github.com/opencloud-eu/opencloud/services/storage-system/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/storage-system/pkg/logging" "github.com/opencloud-eu/opencloud/services/storage-system/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/storage-system/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/storage-system/pkg/config/config.go b/services/storage-system/pkg/config/config.go index a8404c1dc9..98f2ef0c82 100644 --- a/services/storage-system/pkg/config/config.go +++ b/services/storage-system/pkg/config/config.go @@ -9,10 +9,10 @@ import ( // Config holds Config config 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:"loglevel" env:"OC_LOG_LEVEL;STORAGE_SYSTEM_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 HTTPConfig `yaml:"http"` @@ -33,14 +33,6 @@ type Config struct { Context context.Context `yaml:"-"` } -// Log holds Log config -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;STORAGE_SYSTEM_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;STORAGE_SYSTEM_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;STORAGE_SYSTEM_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;STORAGE_SYSTEM_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - // Service holds Service config type Service struct { Name string `yaml:"-"` diff --git a/services/storage-system/pkg/config/defaults/defaultconfig.go b/services/storage-system/pkg/config/defaults/defaultconfig.go index e1de99edc3..9608cd4662 100644 --- a/services/storage-system/pkg/config/defaults/defaultconfig.go +++ b/services/storage-system/pkg/config/defaults/defaultconfig.go @@ -61,18 +61,9 @@ 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.Reva == nil && cfg.Commons != nil { cfg.Reva = structs.CopyOrZeroValue(cfg.Commons.Reva) } diff --git a/services/storage-system/pkg/logging/logging.go b/services/storage-system/pkg/logging/logging.go deleted file mode 100644 index 8aff7304f9..0000000000 --- a/services/storage-system/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/storage-system/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), - ) -} diff --git a/services/storage-users/pkg/command/health.go b/services/storage-users/pkg/command/health.go index 802cec278b..aab48cbaa8 100644 --- a/services/storage-users/pkg/command/health.go +++ b/services/storage-users/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/storage-users/pkg/config" "github.com/opencloud-eu/opencloud/services/storage-users/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/storage-users/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/storage-users/pkg/command/server.go b/services/storage-users/pkg/command/server.go index 1b7bb72bef..5e05ebd949 100644 --- a/services/storage-users/pkg/command/server.go +++ b/services/storage-users/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" "github.com/opencloud-eu/opencloud/pkg/tracing" @@ -13,7 +14,6 @@ import ( "github.com/opencloud-eu/opencloud/services/storage-users/pkg/config" "github.com/opencloud-eu/opencloud/services/storage-users/pkg/config/parser" "github.com/opencloud-eu/opencloud/services/storage-users/pkg/event" - "github.com/opencloud-eu/opencloud/services/storage-users/pkg/logging" "github.com/opencloud-eu/opencloud/services/storage-users/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/storage-users/pkg/server/debug" "github.com/opencloud-eu/reva/v2/cmd/revad/runtime" @@ -31,7 +31,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/storage-users/pkg/config/config.go b/services/storage-users/pkg/config/config.go index f6327df022..104780a2e3 100644 --- a/services/storage-users/pkg/config/config.go +++ b/services/storage-users/pkg/config/config.go @@ -9,10 +9,10 @@ import ( // Config is the configuration for the storage-users service 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:"loglevel" env:"OC_LOG_LEVEL;STORAGE_USERS_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 HTTPConfig `yaml:"http"` @@ -47,14 +47,6 @@ type Config struct { Context context.Context `yaml:"-"` } -// Log configures the logging -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;STORAGE_USERS_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;STORAGE_USERS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;STORAGE_USERS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;STORAGE_USERS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} - // Service holds general service configuration type Service struct { Name string `yaml:"-" env:"STORAGE_USERS_SERVICE_NAME" desc:"Service name to use. Change this when starting an additional storage provider with a custom configuration to prevent it from colliding with the default 'storage-users' service." introductionVersion:"1.0.0"` diff --git a/services/storage-users/pkg/config/defaults/defaultconfig.go b/services/storage-users/pkg/config/defaults/defaultconfig.go index 1a94c8d439..fe7e17c9b0 100644 --- a/services/storage-users/pkg/config/defaults/defaultconfig.go +++ b/services/storage-users/pkg/config/defaults/defaultconfig.go @@ -184,16 +184,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.Reva == nil && cfg.Commons != nil { diff --git a/services/storage-users/pkg/logging/logging.go b/services/storage-users/pkg/logging/logging.go deleted file mode 100644 index 5f8089772a..0000000000 --- a/services/storage-users/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/storage-users/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), - ) -} diff --git a/services/thumbnails/pkg/command/health.go b/services/thumbnails/pkg/command/health.go index 8319313790..3a93c47462 100644 --- a/services/thumbnails/pkg/command/health.go +++ b/services/thumbnails/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/thumbnails/pkg/config" "github.com/opencloud-eu/opencloud/services/thumbnails/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/thumbnails/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/thumbnails/pkg/command/server.go b/services/thumbnails/pkg/command/server.go index 1f99884288..e9a0183f5f 100644 --- a/services/thumbnails/pkg/command/server.go +++ b/services/thumbnails/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/runner" ogrpc "github.com/opencloud-eu/opencloud/pkg/service/grpc" "github.com/opencloud-eu/opencloud/pkg/tracing" "github.com/opencloud-eu/opencloud/pkg/version" "github.com/opencloud-eu/opencloud/services/thumbnails/pkg/config" "github.com/opencloud-eu/opencloud/services/thumbnails/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/thumbnails/pkg/logging" "github.com/opencloud-eu/opencloud/services/thumbnails/pkg/metrics" "github.com/opencloud-eu/opencloud/services/thumbnails/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/thumbnails/pkg/server/grpc" @@ -30,7 +30,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 { diff --git a/services/thumbnails/pkg/config/config.go b/services/thumbnails/pkg/config/config.go index cd2f407b99..408503b718 100644 --- a/services/thumbnails/pkg/config/config.go +++ b/services/thumbnails/pkg/config/config.go @@ -14,8 +14,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;THUMBNAILS_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"` diff --git a/services/thumbnails/pkg/config/defaults/defaultconfig.go b/services/thumbnails/pkg/config/defaults/defaultconfig.go index 949823d546..ede8412133 100644 --- a/services/thumbnails/pkg/config/defaults/defaultconfig.go +++ b/services/thumbnails/pkg/config/defaults/defaultconfig.go @@ -64,16 +64,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/thumbnails/pkg/config/log.go b/services/thumbnails/pkg/config/log.go deleted file mode 100644 index 4e3cea917f..0000000000 --- a/services/thumbnails/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;THUMBNAILS_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;THUMBNAILS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;THUMBNAILS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;THUMBNAILS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/thumbnails/pkg/logging/logging.go b/services/thumbnails/pkg/logging/logging.go deleted file mode 100644 index 942e50f0c8..0000000000 --- a/services/thumbnails/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/thumbnails/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), - ) -} diff --git a/services/userlog/pkg/command/server.go b/services/userlog/pkg/command/server.go index 3021fddc3a..445bb6810e 100644 --- a/services/userlog/pkg/command/server.go +++ b/services/userlog/pkg/command/server.go @@ -7,6 +7,7 @@ import ( "github.com/opencloud-eu/opencloud/pkg/config/configlog" "github.com/opencloud-eu/opencloud/pkg/generators" + "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" @@ -16,7 +17,6 @@ import ( settingssvc "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/services/settings/v0" "github.com/opencloud-eu/opencloud/services/userlog/pkg/config" "github.com/opencloud-eu/opencloud/services/userlog/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/userlog/pkg/logging" "github.com/opencloud-eu/opencloud/services/userlog/pkg/metrics" "github.com/opencloud-eu/opencloud/services/userlog/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/userlog/pkg/server/http" @@ -56,7 +56,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) tracerProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name) if err != nil { return err diff --git a/services/userlog/pkg/config/config.go b/services/userlog/pkg/config/config.go index ac3ff16089..ff2d440e09 100644 --- a/services/userlog/pkg/config/config.go +++ b/services/userlog/pkg/config/config.go @@ -13,8 +13,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;USERLOG_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 HTTP `yaml:"http"` GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` diff --git a/services/userlog/pkg/config/defaults/defaultconfig.go b/services/userlog/pkg/config/defaults/defaultconfig.go index 72e4a9af4f..b8e40eea88 100644 --- a/services/userlog/pkg/config/defaults/defaultconfig.go +++ b/services/userlog/pkg/config/defaults/defaultconfig.go @@ -58,16 +58,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.GRPCClientTLS == nil && cfg.Commons != nil { diff --git a/services/userlog/pkg/config/log.go b/services/userlog/pkg/config/log.go deleted file mode 100644 index 1c37fcb7d2..0000000000 --- a/services/userlog/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;USERLOG_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;USERLOG_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;USERLOG_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;USERLOG_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/userlog/pkg/logging/logging.go b/services/userlog/pkg/logging/logging.go deleted file mode 100644 index cdebe12dde..0000000000 --- a/services/userlog/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/userlog/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), - ) -} diff --git a/services/users/pkg/command/health.go b/services/users/pkg/command/health.go index 6f4893b9f8..b1a3762e7a 100644 --- a/services/users/pkg/command/health.go +++ b/services/users/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/users/pkg/config" "github.com/opencloud-eu/opencloud/services/users/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/users/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/users/pkg/command/server.go b/services/users/pkg/command/server.go index 3f6bc2ae36..a73b977d08 100644 --- a/services/users/pkg/command/server.go +++ b/services/users/pkg/command/server.go @@ -7,13 +7,13 @@ import ( "github.com/opencloud-eu/opencloud/pkg/config/configlog" "github.com/opencloud-eu/opencloud/pkg/ldap" + "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/users/pkg/config" "github.com/opencloud-eu/opencloud/services/users/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/users/pkg/logging" "github.com/opencloud-eu/opencloud/services/users/pkg/revaconfig" "github.com/opencloud-eu/opencloud/services/users/pkg/server/debug" "github.com/opencloud-eu/reva/v2/cmd/revad/runtime" @@ -30,7 +30,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/users/pkg/config/config.go b/services/users/pkg/config/config.go index 57c7783d8a..f9b667c8c0 100644 --- a/services/users/pkg/config/config.go +++ b/services/users/pkg/config/config.go @@ -7,10 +7,10 @@ import ( ) 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:"loglevel" env:"OC_LOG_LEVEL;USERS_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"` @@ -24,12 +24,6 @@ type Config struct { Context context.Context `yaml:"-"` } -type Log struct { - Level string `yaml:"level" env:"OC_LOG_LEVEL;USERS_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;USERS_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `yaml:"color" env:"OC_LOG_COLOR;USERS_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `yaml:"file" env:"OC_LOG_FILE;USERS_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} type Service struct { Name string `yaml:"-"` diff --git a/services/users/pkg/config/defaults/defaultconfig.go b/services/users/pkg/config/defaults/defaultconfig.go index bed8a152b7..a604080dea 100644 --- a/services/users/pkg/config/defaults/defaultconfig.go +++ b/services/users/pkg/config/defaults/defaultconfig.go @@ -89,16 +89,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.Reva == nil && cfg.Commons != nil { diff --git a/services/users/pkg/logging/logging.go b/services/users/pkg/logging/logging.go deleted file mode 100644 index aaa6faa2ec..0000000000 --- a/services/users/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/users/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), - ) -} diff --git a/services/web/pkg/command/health.go b/services/web/pkg/command/health.go index c2b951e696..cf831c16f8 100644 --- a/services/web/pkg/command/health.go +++ b/services/web/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/web/pkg/config" "github.com/opencloud-eu/opencloud/services/web/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/web/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/web/pkg/command/server.go b/services/web/pkg/command/server.go index e8f0f2067e..38df9caec4 100644 --- a/services/web/pkg/command/server.go +++ b/services/web/pkg/command/server.go @@ -8,11 +8,11 @@ import ( "os/signal" "github.com/opencloud-eu/opencloud/pkg/config/configlog" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/pkg/runner" "github.com/opencloud-eu/opencloud/pkg/tracing" "github.com/opencloud-eu/opencloud/services/web/pkg/config" "github.com/opencloud-eu/opencloud/services/web/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/web/pkg/logging" "github.com/opencloud-eu/opencloud/services/web/pkg/metrics" "github.com/opencloud-eu/opencloud/services/web/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/web/pkg/server/http" @@ -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/web/pkg/config/config.go b/services/web/pkg/config/config.go index c304c6d3c6..e2edcab53a 100644 --- a/services/web/pkg/config/config.go +++ b/services/web/pkg/config/config.go @@ -12,8 +12,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;WEB_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 HTTP `yaml:"http"` diff --git a/services/web/pkg/config/defaults/defaultconfig.go b/services/web/pkg/config/defaults/defaultconfig.go index 6286414cee..138daac778 100644 --- a/services/web/pkg/config/defaults/defaultconfig.go +++ b/services/web/pkg/config/defaults/defaultconfig.go @@ -119,16 +119,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.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/web/pkg/config/log.go b/services/web/pkg/config/log.go deleted file mode 100644 index 4b82fe2365..0000000000 --- a/services/web/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;WEB_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;WEB_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;WEB_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;WEB_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/web/pkg/logging/logging.go b/services/web/pkg/logging/logging.go deleted file mode 100644 index 20ce81534b..0000000000 --- a/services/web/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/web/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), - ) -} diff --git a/services/webdav/pkg/command/health.go b/services/webdav/pkg/command/health.go index ae8cd68599..51b27584e1 100644 --- a/services/webdav/pkg/command/health.go +++ b/services/webdav/pkg/command/health.go @@ -5,10 +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/webdav/pkg/config" "github.com/opencloud-eu/opencloud/services/webdav/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/webdav/pkg/logging" - "github.com/spf13/cobra" ) @@ -21,7 +20,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/webdav/pkg/command/server.go b/services/webdav/pkg/command/server.go index b930695d48..8469706291 100644 --- a/services/webdav/pkg/command/server.go +++ b/services/webdav/pkg/command/server.go @@ -6,17 +6,16 @@ import ( "os/signal" "github.com/opencloud-eu/opencloud/pkg/config/configlog" + "github.com/opencloud-eu/opencloud/pkg/log" "github.com/opencloud-eu/opencloud/pkg/runner" ogrpc "github.com/opencloud-eu/opencloud/pkg/service/grpc" "github.com/opencloud-eu/opencloud/pkg/tracing" "github.com/opencloud-eu/opencloud/pkg/version" "github.com/opencloud-eu/opencloud/services/webdav/pkg/config" "github.com/opencloud-eu/opencloud/services/webdav/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/webdav/pkg/logging" "github.com/opencloud-eu/opencloud/services/webdav/pkg/metrics" "github.com/opencloud-eu/opencloud/services/webdav/pkg/server/debug" "github.com/opencloud-eu/opencloud/services/webdav/pkg/server/http" - "github.com/spf13/cobra" ) @@ -29,7 +28,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/webdav/pkg/config/config.go b/services/webdav/pkg/config/config.go index 8c4c7be40f..324704464c 100644 --- a/services/webdav/pkg/config/config.go +++ b/services/webdav/pkg/config/config.go @@ -13,8 +13,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;WEBDAV_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"1.0.0"` + Debug Debug `yaml:"debug"` GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"` GrpcClient client.Client `yaml:"-"` diff --git a/services/webdav/pkg/config/defaults/defaultconfig.go b/services/webdav/pkg/config/defaults/defaultconfig.go index 38dec14008..7bf35b7b01 100644 --- a/services/webdav/pkg/config/defaults/defaultconfig.go +++ b/services/webdav/pkg/config/defaults/defaultconfig.go @@ -47,16 +47,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/webdav/pkg/config/log.go b/services/webdav/pkg/config/log.go deleted file mode 100644 index 22e9f08add..0000000000 --- a/services/webdav/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;WEBDAV_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;WEBDAV_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;WEBDAV_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;WEBDAV_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/webdav/pkg/logging/logging.go b/services/webdav/pkg/logging/logging.go deleted file mode 100644 index 6b06e3b0b3..0000000000 --- a/services/webdav/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/webdav/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), - ) -} diff --git a/services/webfinger/pkg/command/health.go b/services/webfinger/pkg/command/health.go index df5be2a710..16bcf1b71b 100644 --- a/services/webfinger/pkg/command/health.go +++ b/services/webfinger/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/webfinger/pkg/config" "github.com/opencloud-eu/opencloud/services/webfinger/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/webfinger/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/webfinger/pkg/command/server.go b/services/webfinger/pkg/command/server.go index fb93d0868d..74c8fa6881 100644 --- a/services/webfinger/pkg/command/server.go +++ b/services/webfinger/pkg/command/server.go @@ -6,12 +6,12 @@ import ( "os/signal" "github.com/opencloud-eu/opencloud/pkg/config/configlog" + "github.com/opencloud-eu/opencloud/pkg/log" "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/webfinger/pkg/config" "github.com/opencloud-eu/opencloud/services/webfinger/pkg/config/parser" - "github.com/opencloud-eu/opencloud/services/webfinger/pkg/logging" "github.com/opencloud-eu/opencloud/services/webfinger/pkg/metrics" "github.com/opencloud-eu/opencloud/services/webfinger/pkg/relations" "github.com/opencloud-eu/opencloud/services/webfinger/pkg/server/debug" @@ -30,7 +30,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/webfinger/pkg/config/config.go b/services/webfinger/pkg/config/config.go index 7055a97ee7..dc3518aa2d 100644 --- a/services/webfinger/pkg/config/config.go +++ b/services/webfinger/pkg/config/config.go @@ -12,8 +12,8 @@ type Config struct { Service Service `yaml:"-"` - Log *Log `yaml:"log"` - Debug Debug `yaml:"debug"` + LogLevel string `yaml:"loglevel" env:"OC_LOG_LEVEL;WEBFINGER_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 HTTP `yaml:"http"` diff --git a/services/webfinger/pkg/config/defaults/defaultconfig.go b/services/webfinger/pkg/config/defaults/defaultconfig.go index 3d698ce7ff..bea1905a77 100644 --- a/services/webfinger/pkg/config/defaults/defaultconfig.go +++ b/services/webfinger/pkg/config/defaults/defaultconfig.go @@ -56,16 +56,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.Commons != nil { diff --git a/services/webfinger/pkg/config/log.go b/services/webfinger/pkg/config/log.go deleted file mode 100644 index 45b137decd..0000000000 --- a/services/webfinger/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;WEBFINGER_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;WEBFINGER_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"` - Color bool `mapstructure:"color" env:"OC_LOG_COLOR;WEBFINGER_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"` - File string `mapstructure:"file" env:"OC_LOG_FILE;WEBFINGER_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set." introductionVersion:"1.0.0"` -} diff --git a/services/webfinger/pkg/logging/logging.go b/services/webfinger/pkg/logging/logging.go deleted file mode 100644 index 98756b62dc..0000000000 --- a/services/webfinger/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/webfinger/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), - ) -}