Skip to content

Commit 38de4e0

Browse files
committed
consolidate log config in auth-service
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
1 parent bcfb257 commit 38de4e0

File tree

5 files changed

+10
-42
lines changed

5 files changed

+10
-42
lines changed

services/auth-service/pkg/command/health.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"net/http"
66

77
"github.com/opencloud-eu/opencloud/pkg/config/configlog"
8+
"github.com/opencloud-eu/opencloud/pkg/log"
89
"github.com/opencloud-eu/opencloud/services/auth-service/pkg/config"
910
"github.com/opencloud-eu/opencloud/services/auth-service/pkg/config/parser"
10-
"github.com/opencloud-eu/opencloud/services/auth-service/pkg/logging"
1111

1212
"github.com/spf13/cobra"
1313
)
@@ -21,7 +21,7 @@ func Health(cfg *config.Config) *cobra.Command {
2121
return configlog.ReturnError(parser.ParseConfig(cfg))
2222
},
2323
RunE: func(cmd *cobra.Command, args []string) error {
24-
logger := logging.Configure(cfg.Service.Name, cfg.Log)
24+
logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel)
2525

2626
resp, err := http.Get(
2727
fmt.Sprintf(

services/auth-service/pkg/command/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"os/signal"
77

88
"github.com/opencloud-eu/opencloud/pkg/config/configlog"
9+
"github.com/opencloud-eu/opencloud/pkg/log"
910
"github.com/opencloud-eu/opencloud/pkg/registry"
1011
"github.com/opencloud-eu/opencloud/pkg/runner"
1112
"github.com/opencloud-eu/opencloud/pkg/tracing"
1213
"github.com/opencloud-eu/opencloud/pkg/version"
1314
"github.com/opencloud-eu/opencloud/services/auth-service/pkg/config"
1415
"github.com/opencloud-eu/opencloud/services/auth-service/pkg/config/parser"
15-
"github.com/opencloud-eu/opencloud/services/auth-service/pkg/logging"
1616
"github.com/opencloud-eu/opencloud/services/auth-service/pkg/revaconfig"
1717
"github.com/opencloud-eu/opencloud/services/auth-service/pkg/server/debug"
1818
"github.com/opencloud-eu/reva/v2/cmd/revad/runtime"
@@ -29,7 +29,7 @@ func Server(cfg *config.Config) *cobra.Command {
2929
return configlog.ReturnFatal(parser.ParseConfig(cfg))
3030
},
3131
RunE: func(cmd *cobra.Command, args []string) error {
32-
logger := logging.Configure(cfg.Service.Name, cfg.Log)
32+
logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel)
3333
traceProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name)
3434
if err != nil {
3535
return err

services/auth-service/pkg/config/config.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
)
88

99
type Config struct {
10-
Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service
11-
Service Service `yaml:"-"`
12-
Log *Log `yaml:"log"`
13-
Debug Debug `yaml:"debug"`
10+
Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service
11+
Service Service `yaml:"-"`
12+
LogLevel 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"`
13+
Debug Debug `yaml:"debug"`
1414

1515
GRPC GRPCConfig `yaml:"grpc"`
1616

@@ -23,13 +23,6 @@ type Config struct {
2323
Context context.Context `yaml:"-"`
2424
}
2525

26-
type Log struct {
27-
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"`
28-
Pretty bool `yaml:"pretty" env:"OC_LOG_PRETTY;AUTH_SERVICE_LOG_PRETTY" desc:"Activates pretty log output." introductionVersion:"1.0.0"`
29-
Color bool `yaml:"color" env:"OC_LOG_COLOR;AUTH_SERVICE_LOG_COLOR" desc:"Activates colorized log output." introductionVersion:"1.0.0"`
30-
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"`
31-
}
32-
3326
type Service struct {
3427
Name string `yaml:"-"`
3528
}

services/auth-service/pkg/config/defaults/defaultconfig.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,8 @@ func DefaultConfig() *config.Config {
3737

3838
// EnsureDefaults adds default values to the configuration if they are not set yet
3939
func EnsureDefaults(cfg *config.Config) {
40-
// provide with defaults for shared logging, since we need a valid destination address for "envdecode".
41-
if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil {
42-
cfg.Log = &config.Log{
43-
Level: cfg.Commons.Log.Level,
44-
Pretty: cfg.Commons.Log.Pretty,
45-
Color: cfg.Commons.Log.Color,
46-
File: cfg.Commons.Log.File,
47-
}
48-
} else if cfg.Log == nil {
49-
cfg.Log = &config.Log{}
40+
if cfg.LogLevel == "" {
41+
cfg.LogLevel = "error"
5042
}
5143

5244
if cfg.Reva == nil && cfg.Commons != nil {

services/auth-service/pkg/logging/logging.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)