Skip to content

Commit e6a5aae

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

File tree

5 files changed

+6
-39
lines changed

5 files changed

+6
-39
lines changed

services/clientlog/pkg/command/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import (
77

88
"github.com/opencloud-eu/opencloud/pkg/config/configlog"
99
"github.com/opencloud-eu/opencloud/pkg/generators"
10+
"github.com/opencloud-eu/opencloud/pkg/log"
1011
"github.com/opencloud-eu/opencloud/pkg/registry"
1112
"github.com/opencloud-eu/opencloud/pkg/runner"
1213
"github.com/opencloud-eu/opencloud/pkg/tracing"
1314
"github.com/opencloud-eu/opencloud/pkg/version"
1415
"github.com/opencloud-eu/opencloud/services/clientlog/pkg/config"
1516
"github.com/opencloud-eu/opencloud/services/clientlog/pkg/config/parser"
16-
"github.com/opencloud-eu/opencloud/services/clientlog/pkg/logging"
1717
"github.com/opencloud-eu/opencloud/services/clientlog/pkg/metrics"
1818
"github.com/opencloud-eu/opencloud/services/clientlog/pkg/server/debug"
1919
"github.com/opencloud-eu/opencloud/services/clientlog/pkg/service"
@@ -55,7 +55,7 @@ func Server(cfg *config.Config) *cobra.Command {
5555
return configlog.ReturnFatal(parser.ParseConfig(cfg))
5656
},
5757
RunE: func(cmd *cobra.Command, args []string) error {
58-
logger := logging.Configure(cfg.Service.Name, cfg.Log)
58+
logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel)
5959
tracerProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name)
6060
if err != nil {
6161
return err

services/clientlog/pkg/config/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ type Config struct {
1212

1313
Service Service `yaml:"-"`
1414

15-
Log *Log `yaml:"log"`
15+
LogLevel 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"`
16+
1617
Debug Debug `yaml:"debug"`
1718

1819
GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"`

services/clientlog/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 ensures the config contains default values
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.GRPCClientTLS == nil && cfg.Commons != nil {

services/clientlog/pkg/config/log.go

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

services/clientlog/pkg/logging/logging.go

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

0 commit comments

Comments
 (0)