From 33f6ee34fcd85c4f0f4094ad0e7f7cdad26d4ad7 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Tue, 5 Jul 2022 13:43:48 +0200 Subject: [PATCH 1/3] fix logging levels and go-micro logging format --- changelog/unreleased/fix-logging-levels.md | 15 ++ ocis-pkg/log/gomicro/log.go | 33 +++++ ocis-pkg/log/log.go | 129 ++---------------- ocis/pkg/runtime/service/service.go | 21 +-- .../app-provider/cmd/app-provider/main.go | 1 + .../app-registry/cmd/app-registry/main.go | 1 + services/audit/cmd/audit/main.go | 1 + services/auth-basic/cmd/auth-basic/main.go | 1 + services/auth-bearer/cmd/auth-bearer/main.go | 1 + .../auth-machine/cmd/auth-machine/main.go | 1 + services/frontend/cmd/frontend/main.go | 1 + services/gateway/cmd/gateway/main.go | 1 + .../graph-explorer/cmd/graph-explorer/main.go | 1 + services/graph/cmd/graph/main.go | 1 + services/groups/cmd/groups/main.go | 1 + services/idm/cmd/idm/main.go | 1 + services/idp/cmd/idp/main.go | 1 + services/nats/cmd/nats/main.go | 1 + .../notifications/cmd/notifications/main.go | 1 + services/ocdav/cmd/ocdav/main.go | 1 + services/ocs/cmd/ocs/main.go | 1 + services/proxy/cmd/proxy/main.go | 1 + services/search/cmd/search/main.go | 1 + services/settings/cmd/settings/main.go | 1 + services/sharing/cmd/sharing/main.go | 1 + .../cmd/storage-publiclink/main.go | 1 + .../storage-shares/cmd/storage-shares/main.go | 1 + .../storage-system/cmd/storage-system/main.go | 1 + .../storage-users/cmd/storage-users/main.go | 1 + services/store/cmd/store/main.go | 1 + services/thumbnails/cmd/thumbnails/main.go | 1 + services/users/cmd/user/main.go | 1 + services/web/cmd/web/main.go | 1 + services/webdav/cmd/webdav/main.go | 1 + 34 files changed, 93 insertions(+), 135 deletions(-) create mode 100644 changelog/unreleased/fix-logging-levels.md create mode 100644 ocis-pkg/log/gomicro/log.go diff --git a/changelog/unreleased/fix-logging-levels.md b/changelog/unreleased/fix-logging-levels.md new file mode 100644 index 00000000000..3e0b33b021d --- /dev/null +++ b/changelog/unreleased/fix-logging-levels.md @@ -0,0 +1,15 @@ +Bugfix: Fix logging levels + +We've fixed the configuration of logging levels. Previously it was not possible +to configure a service with a more or less verbose log level then all other services +when running in the supervised / runtime mode `ocis server`. + +For example `OCIS_LOG_LEVEL=error PROXY_LOG_LEVEL=debug ocis server` did not configure +error logging for all services except the proxy, which should be on debug logging. This is now fixed +and working properly. + +Also we fixed the format of go-micro logs to always default to error level. +Previously this was only ensured in the supervised / runtime mode. + +https://github.com/owncloud/ocis/pull/4102 +https://github.com/owncloud/ocis/issues/4089 diff --git a/ocis-pkg/log/gomicro/log.go b/ocis-pkg/log/gomicro/log.go new file mode 100644 index 00000000000..63b3b8a2be0 --- /dev/null +++ b/ocis-pkg/log/gomicro/log.go @@ -0,0 +1,33 @@ +package gomicro + +import ( + "os" + + mzlog "github.com/go-micro/plugins/v4/logger/zerolog" + "github.com/rs/zerolog" + "go-micro.dev/v4/logger" +) + +func init() { + // this is ugly, but "logger.DefaultLogger" is a global variable and we need to set it _before_ anybody uses it + setMicroLogger() +} + +// for logging reasons we don't want the same logging level on both oCIS and micro. As a framework builder we do not +// want to expose to the end user the internal framework logs unless explicitly specified. +func setMicroLogger() { + if os.Getenv("MICRO_LOG_LEVEL") == "" { + _ = os.Setenv("MICRO_LOG_LEVEL", "error") + } + + lev, err := zerolog.ParseLevel(os.Getenv("MICRO_LOG_LEVEL")) + if err != nil { + lev = zerolog.ErrorLevel + } + logger.DefaultLogger = mzlog.NewLogger( + logger.WithLevel(logger.Level(lev)), + logger.WithFields(map[string]interface{}{ + "system": "go-micro", + }), + ) +} diff --git a/ocis-pkg/log/log.go b/ocis-pkg/log/log.go index ea33f50741c..e90fa1dcb30 100644 --- a/ocis-pkg/log/log.go +++ b/ocis-pkg/log/log.go @@ -10,9 +10,6 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" - mdlog "go-micro.dev/v4/debug/log" - mlog "go-micro.dev/v4/util/log" - "go-micro.dev/v4/util/ring" ) // Logger simply wraps the zerolog logger. @@ -35,31 +32,27 @@ func LoggerFromConfig(name string, cfg *shared.Log) Logger { func NewLogger(opts ...Option) Logger { options := newOptions(opts...) + // set GlobalLevel() to the minimum value -1 = TraceLevel, so that only the services' log level matter + zerolog.SetGlobalLevel(zerolog.TraceLevel) + + var logLevel zerolog.Level switch strings.ToLower(options.Level) { case "panic": - zerolog.SetGlobalLevel(zerolog.PanicLevel) - mlog.SetLevel(mlog.LevelFatal) + logLevel = zerolog.PanicLevel case "fatal": - zerolog.SetGlobalLevel(zerolog.FatalLevel) - mlog.SetLevel(mlog.LevelFatal) + logLevel = zerolog.FatalLevel case "error": - zerolog.SetGlobalLevel(zerolog.ErrorLevel) - mlog.SetLevel(mlog.LevelError) + logLevel = zerolog.ErrorLevel case "warn": - zerolog.SetGlobalLevel(zerolog.WarnLevel) - mlog.SetLevel(mlog.LevelWarn) + logLevel = zerolog.WarnLevel case "info": - zerolog.SetGlobalLevel(zerolog.InfoLevel) - mlog.SetLevel(mlog.LevelInfo) + logLevel = zerolog.InfoLevel case "debug": - zerolog.SetGlobalLevel(zerolog.DebugLevel) - mlog.SetLevel(mlog.LevelDebug) + logLevel = zerolog.DebugLevel case "trace": - zerolog.SetGlobalLevel(zerolog.DebugLevel) - mlog.SetLevel(mlog.LevelTrace) + logLevel = zerolog.TraceLevel default: - zerolog.SetGlobalLevel(zerolog.ErrorLevel) - mlog.SetLevel(mlog.LevelError) + logLevel = zerolog.ErrorLevel } var logger zerolog.Logger @@ -88,105 +81,9 @@ func NewLogger(opts ...Option) Logger { logger = logger.With(). Str("service", options.Name). Timestamp(). - Logger() - - mlog.SetLogger( - microZerolog{ - logger: logger, - buffer: ring.New(mdlog.DefaultSize), - }, - ) + Logger().Level(logLevel) return Logger{ logger, } } - -// microZerolog implements the required interface for the go-micro logger. -type microZerolog struct { - logger zerolog.Logger - buffer *ring.Buffer -} - -func (mz microZerolog) Read(opts ...mdlog.ReadOption) ([]mdlog.Record, error) { - options := mdlog.ReadOptions{} - for _, o := range opts { - o(&options) - } - - var entries []*ring.Entry - - if !options.Since.IsZero() { - entries = mz.buffer.Since(options.Since) - } - - if options.Count > 0 { - switch len(entries) > 0 { - case true: - if options.Count > len(entries) { - entries = entries[0:options.Count] - } - default: - entries = mz.buffer.Get(options.Count) - } - } - - records := make([]mdlog.Record, 0, len(entries)) - for _, entry := range entries { - record := mdlog.Record{ - Timestamp: entry.Timestamp, - Message: entry.Value, - } - records = append(records, record) - } - - return records, nil -} - -func (mz microZerolog) Write(record mdlog.Record) error { - level := record.Metadata["level"] - mz.log(level, fmt.Sprint(record.Message)) - mz.buffer.Put(record.Message) - return nil -} - -func (mz microZerolog) Stream() (mdlog.Stream, error) { - stream, stop := mz.buffer.Stream() - records := make(chan mdlog.Record, 128) - last10 := mz.buffer.Get(10) - - go func() { - for _, entry := range last10 { - records <- mdlog.Record{ - Timestamp: entry.Timestamp, - Message: entry.Value, - Metadata: make(map[string]string), - } - } - for entry := range stream { - records <- mdlog.Record{ - Timestamp: entry.Timestamp, - Message: entry.Value, - Metadata: make(map[string]string), - } - } - }() - return &logStream{ - stream: records, - stop: stop, - }, nil -} - -func (mz microZerolog) log(level string, msg string) { - l, err := zerolog.ParseLevel(level) - if err != nil { - l = zerolog.InfoLevel - } - - mz.logger.WithLevel(l).Msg(msg) - - // Invoke os.Exit because unlike zerolog.Logger.Fatal zerolog.Logger.WithLevel won't stop the execution. - if l == zerolog.FatalLevel { - os.Exit(1) - } -} diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index dc5e76bfdbd..4c053209baf 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -15,7 +15,6 @@ import ( "github.com/owncloud/ocis/v2/ocis-pkg/shared" - mzlog "github.com/go-micro/plugins/v4/logger/zerolog" "github.com/mohae/deepcopy" "github.com/olekukonko/tablewriter" @@ -50,9 +49,9 @@ import ( users "github.com/owncloud/ocis/v2/services/users/pkg/command" web "github.com/owncloud/ocis/v2/services/web/pkg/command" webdav "github.com/owncloud/ocis/v2/services/webdav/pkg/command" - "github.com/rs/zerolog" "github.com/thejerf/suture/v4" - "go-micro.dev/v4/logger" + + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" ) var ( @@ -157,8 +156,6 @@ func Start(o ...Option) error { halt := make(chan os.Signal, 1) signal.Notify(halt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) - setMicroLogger() - // tolerance controls backoff cycles from the supervisor. tolerance := 5 totalBackoff := 0 @@ -301,17 +298,3 @@ func trap(s *Service, halt chan os.Signal) { s.Log.Debug().Str("service", "runtime service").Msgf("terminating with signal: %v", s) os.Exit(0) } - -// for logging reasons we don't want the same logging level on both oCIS and micro. As a framework builder we do not -// want to expose to the end user the internal framework logs unless explicitly specified. -func setMicroLogger() { - if os.Getenv("MICRO_LOG_LEVEL") == "" { - _ = os.Setenv("MICRO_LOG_LEVEL", "error") - } - - lev, err := zerolog.ParseLevel(os.Getenv("MICRO_LOG_LEVEL")) - if err != nil { - lev = zerolog.ErrorLevel - } - logger.DefaultLogger = mzlog.NewLogger(logger.WithLevel(logger.Level(lev))) -} diff --git a/services/app-provider/cmd/app-provider/main.go b/services/app-provider/cmd/app-provider/main.go index c4afd562c2d..d70739cee02 100644 --- a/services/app-provider/cmd/app-provider/main.go +++ b/services/app-provider/cmd/app-provider/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/app-provider/pkg/command" "github.com/owncloud/ocis/v2/services/app-provider/pkg/config/defaults" ) diff --git a/services/app-registry/cmd/app-registry/main.go b/services/app-registry/cmd/app-registry/main.go index 6a9d91f7d68..1c59dde722e 100644 --- a/services/app-registry/cmd/app-registry/main.go +++ b/services/app-registry/cmd/app-registry/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/app-registry/pkg/command" "github.com/owncloud/ocis/v2/services/app-registry/pkg/config/defaults" ) diff --git a/services/audit/cmd/audit/main.go b/services/audit/cmd/audit/main.go index f365e874ec3..18b8ceb25a5 100644 --- a/services/audit/cmd/audit/main.go +++ b/services/audit/cmd/audit/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/audit/pkg/command" "github.com/owncloud/ocis/v2/services/audit/pkg/config/defaults" ) diff --git a/services/auth-basic/cmd/auth-basic/main.go b/services/auth-basic/cmd/auth-basic/main.go index ec5af41edf3..572feb4cf3f 100644 --- a/services/auth-basic/cmd/auth-basic/main.go +++ b/services/auth-basic/cmd/auth-basic/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/command" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/config/defaults" ) diff --git a/services/auth-bearer/cmd/auth-bearer/main.go b/services/auth-bearer/cmd/auth-bearer/main.go index 8617701cfde..808f449861b 100644 --- a/services/auth-bearer/cmd/auth-bearer/main.go +++ b/services/auth-bearer/cmd/auth-bearer/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/command" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/config/defaults" ) diff --git a/services/auth-machine/cmd/auth-machine/main.go b/services/auth-machine/cmd/auth-machine/main.go index 937b0b20cdf..8d543a6058c 100644 --- a/services/auth-machine/cmd/auth-machine/main.go +++ b/services/auth-machine/cmd/auth-machine/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/command" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config/defaults" ) diff --git a/services/frontend/cmd/frontend/main.go b/services/frontend/cmd/frontend/main.go index cbdc5dac510..48296d2a3c5 100644 --- a/services/frontend/cmd/frontend/main.go +++ b/services/frontend/cmd/frontend/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/frontend/pkg/command" "github.com/owncloud/ocis/v2/services/frontend/pkg/config/defaults" ) diff --git a/services/gateway/cmd/gateway/main.go b/services/gateway/cmd/gateway/main.go index d22e804011a..2eab06a6d31 100644 --- a/services/gateway/cmd/gateway/main.go +++ b/services/gateway/cmd/gateway/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/gateway/pkg/command" "github.com/owncloud/ocis/v2/services/gateway/pkg/config/defaults" ) diff --git a/services/graph-explorer/cmd/graph-explorer/main.go b/services/graph-explorer/cmd/graph-explorer/main.go index 092cd87412f..34d83280437 100644 --- a/services/graph-explorer/cmd/graph-explorer/main.go +++ b/services/graph-explorer/cmd/graph-explorer/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/command" "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config/defaults" ) diff --git a/services/graph/cmd/graph/main.go b/services/graph/cmd/graph/main.go index 7844daa6af9..e899d008606 100644 --- a/services/graph/cmd/graph/main.go +++ b/services/graph/cmd/graph/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/graph/pkg/command" "github.com/owncloud/ocis/v2/services/graph/pkg/config/defaults" ) diff --git a/services/groups/cmd/groups/main.go b/services/groups/cmd/groups/main.go index 2172fc84505..774804a503d 100644 --- a/services/groups/cmd/groups/main.go +++ b/services/groups/cmd/groups/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/groups/pkg/command" "github.com/owncloud/ocis/v2/services/groups/pkg/config/defaults" ) diff --git a/services/idm/cmd/idm/main.go b/services/idm/cmd/idm/main.go index f30202e587d..fbf3d5b5c76 100644 --- a/services/idm/cmd/idm/main.go +++ b/services/idm/cmd/idm/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/idm/pkg/command" "github.com/owncloud/ocis/v2/services/idm/pkg/config/defaults" ) diff --git a/services/idp/cmd/idp/main.go b/services/idp/cmd/idp/main.go index 174283c909a..864e1da308b 100644 --- a/services/idp/cmd/idp/main.go +++ b/services/idp/cmd/idp/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/idp/pkg/command" "github.com/owncloud/ocis/v2/services/idp/pkg/config/defaults" ) diff --git a/services/nats/cmd/nats/main.go b/services/nats/cmd/nats/main.go index 4b5803ac78c..238cd5f6427 100644 --- a/services/nats/cmd/nats/main.go +++ b/services/nats/cmd/nats/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/nats/pkg/command" "github.com/owncloud/ocis/v2/services/nats/pkg/config/defaults" ) diff --git a/services/notifications/cmd/notifications/main.go b/services/notifications/cmd/notifications/main.go index 5d5752af388..0d596381211 100644 --- a/services/notifications/cmd/notifications/main.go +++ b/services/notifications/cmd/notifications/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/notifications/pkg/command" "github.com/owncloud/ocis/v2/services/notifications/pkg/config/defaults" ) diff --git a/services/ocdav/cmd/ocdav/main.go b/services/ocdav/cmd/ocdav/main.go index 9875027bdb5..38f93f5a0de 100644 --- a/services/ocdav/cmd/ocdav/main.go +++ b/services/ocdav/cmd/ocdav/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/ocdav/pkg/command" "github.com/owncloud/ocis/v2/services/ocdav/pkg/config/defaults" ) diff --git a/services/ocs/cmd/ocs/main.go b/services/ocs/cmd/ocs/main.go index a2b9021ead9..25151dfc4f7 100644 --- a/services/ocs/cmd/ocs/main.go +++ b/services/ocs/cmd/ocs/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/ocs/pkg/command" "github.com/owncloud/ocis/v2/services/ocs/pkg/config/defaults" ) diff --git a/services/proxy/cmd/proxy/main.go b/services/proxy/cmd/proxy/main.go index 7db75b5de08..a0cf7844811 100644 --- a/services/proxy/cmd/proxy/main.go +++ b/services/proxy/cmd/proxy/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/proxy/pkg/command" "github.com/owncloud/ocis/v2/services/proxy/pkg/config/defaults" ) diff --git a/services/search/cmd/search/main.go b/services/search/cmd/search/main.go index 70103e7bf00..434161fdd52 100644 --- a/services/search/cmd/search/main.go +++ b/services/search/cmd/search/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/search/pkg/command" "github.com/owncloud/ocis/v2/services/search/pkg/config/defaults" ) diff --git a/services/settings/cmd/settings/main.go b/services/settings/cmd/settings/main.go index 1e21338dd80..7fe28a9ebe4 100644 --- a/services/settings/cmd/settings/main.go +++ b/services/settings/cmd/settings/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/settings/pkg/command" "github.com/owncloud/ocis/v2/services/settings/pkg/config/defaults" ) diff --git a/services/sharing/cmd/sharing/main.go b/services/sharing/cmd/sharing/main.go index 54e0996e3fd..8282d96b70c 100644 --- a/services/sharing/cmd/sharing/main.go +++ b/services/sharing/cmd/sharing/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/sharing/pkg/command" "github.com/owncloud/ocis/v2/services/sharing/pkg/config/defaults" ) diff --git a/services/storage-publiclink/cmd/storage-publiclink/main.go b/services/storage-publiclink/cmd/storage-publiclink/main.go index 6d2415a0070..c15fe2ae92a 100644 --- a/services/storage-publiclink/cmd/storage-publiclink/main.go +++ b/services/storage-publiclink/cmd/storage-publiclink/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/command" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/config/defaults" ) diff --git a/services/storage-shares/cmd/storage-shares/main.go b/services/storage-shares/cmd/storage-shares/main.go index 8a8f9336beb..f59275418bd 100644 --- a/services/storage-shares/cmd/storage-shares/main.go +++ b/services/storage-shares/cmd/storage-shares/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/command" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/config/defaults" ) diff --git a/services/storage-system/cmd/storage-system/main.go b/services/storage-system/cmd/storage-system/main.go index d9242ea0571..34ecd75820c 100644 --- a/services/storage-system/cmd/storage-system/main.go +++ b/services/storage-system/cmd/storage-system/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/storage-system/pkg/command" "github.com/owncloud/ocis/v2/services/storage-system/pkg/config/defaults" ) diff --git a/services/storage-users/cmd/storage-users/main.go b/services/storage-users/cmd/storage-users/main.go index c3c7bc7e3f0..5d0ca3aeb77 100644 --- a/services/storage-users/cmd/storage-users/main.go +++ b/services/storage-users/cmd/storage-users/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/storage-users/pkg/command" "github.com/owncloud/ocis/v2/services/storage-users/pkg/config/defaults" ) diff --git a/services/store/cmd/store/main.go b/services/store/cmd/store/main.go index ecf42e81938..7dfbc496a23 100644 --- a/services/store/cmd/store/main.go +++ b/services/store/cmd/store/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/store/pkg/command" "github.com/owncloud/ocis/v2/services/store/pkg/config/defaults" ) diff --git a/services/thumbnails/cmd/thumbnails/main.go b/services/thumbnails/cmd/thumbnails/main.go index f0a86f58bf2..86bf69d2bd0 100644 --- a/services/thumbnails/cmd/thumbnails/main.go +++ b/services/thumbnails/cmd/thumbnails/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/command" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/config/defaults" ) diff --git a/services/users/cmd/user/main.go b/services/users/cmd/user/main.go index cae358d3c0b..2655b24aa10 100644 --- a/services/users/cmd/user/main.go +++ b/services/users/cmd/user/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/users/pkg/command" "github.com/owncloud/ocis/v2/services/users/pkg/config/defaults" ) diff --git a/services/web/cmd/web/main.go b/services/web/cmd/web/main.go index 9974c37fc9a..d2403a3a689 100644 --- a/services/web/cmd/web/main.go +++ b/services/web/cmd/web/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/web/pkg/command" "github.com/owncloud/ocis/v2/services/web/pkg/config/defaults" ) diff --git a/services/webdav/cmd/webdav/main.go b/services/webdav/cmd/webdav/main.go index 84449ec2e3e..3c811d4011d 100644 --- a/services/webdav/cmd/webdav/main.go +++ b/services/webdav/cmd/webdav/main.go @@ -3,6 +3,7 @@ package main import ( "os" + _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/webdav/pkg/command" "github.com/owncloud/ocis/v2/services/webdav/pkg/config/defaults" ) From 875ad911db704c8ad76e0c03452a3c7b6a9fc620 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Thu, 7 Jul 2022 17:16:28 +0200 Subject: [PATCH 2/3] Fixup previous commit to avoid using blank imports --- ocis-pkg/log/gomicro/log.go | 33 ------------------- ocis-pkg/log/log.go | 27 ++++++++++++++- ocis/pkg/runtime/service/service.go | 21 ++++++++++-- .../app-provider/cmd/app-provider/main.go | 1 - .../app-registry/cmd/app-registry/main.go | 1 - services/audit/cmd/audit/main.go | 1 - services/auth-basic/cmd/auth-basic/main.go | 1 - services/auth-bearer/cmd/auth-bearer/main.go | 1 - .../auth-machine/cmd/auth-machine/main.go | 1 - services/frontend/cmd/frontend/main.go | 1 - services/gateway/cmd/gateway/main.go | 1 - .../graph-explorer/cmd/graph-explorer/main.go | 1 - services/graph/cmd/graph/main.go | 1 - services/groups/cmd/groups/main.go | 1 - services/idm/cmd/idm/main.go | 1 - services/idp/cmd/idp/main.go | 1 - services/nats/cmd/nats/main.go | 1 - .../notifications/cmd/notifications/main.go | 1 - services/ocdav/cmd/ocdav/main.go | 1 - services/ocs/cmd/ocs/main.go | 1 - services/proxy/cmd/proxy/main.go | 1 - services/search/cmd/search/main.go | 1 - services/settings/cmd/settings/main.go | 1 - services/sharing/cmd/sharing/main.go | 1 - .../cmd/storage-publiclink/main.go | 1 - .../storage-shares/cmd/storage-shares/main.go | 1 - .../storage-system/cmd/storage-system/main.go | 1 - .../storage-users/cmd/storage-users/main.go | 1 - services/store/cmd/store/main.go | 1 - services/thumbnails/cmd/thumbnails/main.go | 1 - services/users/cmd/user/main.go | 1 - services/web/cmd/web/main.go | 1 - services/webdav/cmd/webdav/main.go | 1 - 33 files changed, 45 insertions(+), 66 deletions(-) delete mode 100644 ocis-pkg/log/gomicro/log.go diff --git a/ocis-pkg/log/gomicro/log.go b/ocis-pkg/log/gomicro/log.go deleted file mode 100644 index 63b3b8a2be0..00000000000 --- a/ocis-pkg/log/gomicro/log.go +++ /dev/null @@ -1,33 +0,0 @@ -package gomicro - -import ( - "os" - - mzlog "github.com/go-micro/plugins/v4/logger/zerolog" - "github.com/rs/zerolog" - "go-micro.dev/v4/logger" -) - -func init() { - // this is ugly, but "logger.DefaultLogger" is a global variable and we need to set it _before_ anybody uses it - setMicroLogger() -} - -// for logging reasons we don't want the same logging level on both oCIS and micro. As a framework builder we do not -// want to expose to the end user the internal framework logs unless explicitly specified. -func setMicroLogger() { - if os.Getenv("MICRO_LOG_LEVEL") == "" { - _ = os.Setenv("MICRO_LOG_LEVEL", "error") - } - - lev, err := zerolog.ParseLevel(os.Getenv("MICRO_LOG_LEVEL")) - if err != nil { - lev = zerolog.ErrorLevel - } - logger.DefaultLogger = mzlog.NewLogger( - logger.WithLevel(logger.Level(lev)), - logger.WithFields(map[string]interface{}{ - "system": "go-micro", - }), - ) -} diff --git a/ocis-pkg/log/log.go b/ocis-pkg/log/log.go index e90fa1dcb30..14a89d5ea85 100644 --- a/ocis-pkg/log/log.go +++ b/ocis-pkg/log/log.go @@ -6,12 +6,37 @@ import ( "strings" "time" + mzlog "github.com/go-micro/plugins/v4/logger/zerolog" "github.com/owncloud/ocis/v2/ocis-pkg/shared" - "github.com/rs/zerolog" "github.com/rs/zerolog/log" + "go-micro.dev/v4/logger" ) +func init() { + // this is ugly, but "logger.DefaultLogger" is a global variable and we need to set it _before_ anybody uses it + setMicroLogger() +} + +// for logging reasons we don't want the same logging level on both oCIS and micro. As a framework builder we do not +// want to expose to the end user the internal framework logs unless explicitly specified. +func setMicroLogger() { + if os.Getenv("MICRO_LOG_LEVEL") == "" { + _ = os.Setenv("MICRO_LOG_LEVEL", "error") + } + + lev, err := zerolog.ParseLevel(os.Getenv("MICRO_LOG_LEVEL")) + if err != nil { + lev = zerolog.ErrorLevel + } + logger.DefaultLogger = mzlog.NewLogger( + logger.WithLevel(logger.Level(lev)), + logger.WithFields(map[string]interface{}{ + "system": "go-micro", + }), + ) +} + // Logger simply wraps the zerolog logger. type Logger struct { zerolog.Logger diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 4c053209baf..dc5e76bfdbd 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -15,6 +15,7 @@ import ( "github.com/owncloud/ocis/v2/ocis-pkg/shared" + mzlog "github.com/go-micro/plugins/v4/logger/zerolog" "github.com/mohae/deepcopy" "github.com/olekukonko/tablewriter" @@ -49,9 +50,9 @@ import ( users "github.com/owncloud/ocis/v2/services/users/pkg/command" web "github.com/owncloud/ocis/v2/services/web/pkg/command" webdav "github.com/owncloud/ocis/v2/services/webdav/pkg/command" + "github.com/rs/zerolog" "github.com/thejerf/suture/v4" - - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" + "go-micro.dev/v4/logger" ) var ( @@ -156,6 +157,8 @@ func Start(o ...Option) error { halt := make(chan os.Signal, 1) signal.Notify(halt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) + setMicroLogger() + // tolerance controls backoff cycles from the supervisor. tolerance := 5 totalBackoff := 0 @@ -298,3 +301,17 @@ func trap(s *Service, halt chan os.Signal) { s.Log.Debug().Str("service", "runtime service").Msgf("terminating with signal: %v", s) os.Exit(0) } + +// for logging reasons we don't want the same logging level on both oCIS and micro. As a framework builder we do not +// want to expose to the end user the internal framework logs unless explicitly specified. +func setMicroLogger() { + if os.Getenv("MICRO_LOG_LEVEL") == "" { + _ = os.Setenv("MICRO_LOG_LEVEL", "error") + } + + lev, err := zerolog.ParseLevel(os.Getenv("MICRO_LOG_LEVEL")) + if err != nil { + lev = zerolog.ErrorLevel + } + logger.DefaultLogger = mzlog.NewLogger(logger.WithLevel(logger.Level(lev))) +} diff --git a/services/app-provider/cmd/app-provider/main.go b/services/app-provider/cmd/app-provider/main.go index d70739cee02..c4afd562c2d 100644 --- a/services/app-provider/cmd/app-provider/main.go +++ b/services/app-provider/cmd/app-provider/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/app-provider/pkg/command" "github.com/owncloud/ocis/v2/services/app-provider/pkg/config/defaults" ) diff --git a/services/app-registry/cmd/app-registry/main.go b/services/app-registry/cmd/app-registry/main.go index 1c59dde722e..6a9d91f7d68 100644 --- a/services/app-registry/cmd/app-registry/main.go +++ b/services/app-registry/cmd/app-registry/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/app-registry/pkg/command" "github.com/owncloud/ocis/v2/services/app-registry/pkg/config/defaults" ) diff --git a/services/audit/cmd/audit/main.go b/services/audit/cmd/audit/main.go index 18b8ceb25a5..f365e874ec3 100644 --- a/services/audit/cmd/audit/main.go +++ b/services/audit/cmd/audit/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/audit/pkg/command" "github.com/owncloud/ocis/v2/services/audit/pkg/config/defaults" ) diff --git a/services/auth-basic/cmd/auth-basic/main.go b/services/auth-basic/cmd/auth-basic/main.go index 572feb4cf3f..ec5af41edf3 100644 --- a/services/auth-basic/cmd/auth-basic/main.go +++ b/services/auth-basic/cmd/auth-basic/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/command" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/config/defaults" ) diff --git a/services/auth-bearer/cmd/auth-bearer/main.go b/services/auth-bearer/cmd/auth-bearer/main.go index 808f449861b..8617701cfde 100644 --- a/services/auth-bearer/cmd/auth-bearer/main.go +++ b/services/auth-bearer/cmd/auth-bearer/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/command" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/config/defaults" ) diff --git a/services/auth-machine/cmd/auth-machine/main.go b/services/auth-machine/cmd/auth-machine/main.go index 8d543a6058c..937b0b20cdf 100644 --- a/services/auth-machine/cmd/auth-machine/main.go +++ b/services/auth-machine/cmd/auth-machine/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/command" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config/defaults" ) diff --git a/services/frontend/cmd/frontend/main.go b/services/frontend/cmd/frontend/main.go index 48296d2a3c5..cbdc5dac510 100644 --- a/services/frontend/cmd/frontend/main.go +++ b/services/frontend/cmd/frontend/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/frontend/pkg/command" "github.com/owncloud/ocis/v2/services/frontend/pkg/config/defaults" ) diff --git a/services/gateway/cmd/gateway/main.go b/services/gateway/cmd/gateway/main.go index 2eab06a6d31..d22e804011a 100644 --- a/services/gateway/cmd/gateway/main.go +++ b/services/gateway/cmd/gateway/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/gateway/pkg/command" "github.com/owncloud/ocis/v2/services/gateway/pkg/config/defaults" ) diff --git a/services/graph-explorer/cmd/graph-explorer/main.go b/services/graph-explorer/cmd/graph-explorer/main.go index 34d83280437..092cd87412f 100644 --- a/services/graph-explorer/cmd/graph-explorer/main.go +++ b/services/graph-explorer/cmd/graph-explorer/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/command" "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config/defaults" ) diff --git a/services/graph/cmd/graph/main.go b/services/graph/cmd/graph/main.go index e899d008606..7844daa6af9 100644 --- a/services/graph/cmd/graph/main.go +++ b/services/graph/cmd/graph/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/graph/pkg/command" "github.com/owncloud/ocis/v2/services/graph/pkg/config/defaults" ) diff --git a/services/groups/cmd/groups/main.go b/services/groups/cmd/groups/main.go index 774804a503d..2172fc84505 100644 --- a/services/groups/cmd/groups/main.go +++ b/services/groups/cmd/groups/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/groups/pkg/command" "github.com/owncloud/ocis/v2/services/groups/pkg/config/defaults" ) diff --git a/services/idm/cmd/idm/main.go b/services/idm/cmd/idm/main.go index fbf3d5b5c76..f30202e587d 100644 --- a/services/idm/cmd/idm/main.go +++ b/services/idm/cmd/idm/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/idm/pkg/command" "github.com/owncloud/ocis/v2/services/idm/pkg/config/defaults" ) diff --git a/services/idp/cmd/idp/main.go b/services/idp/cmd/idp/main.go index 864e1da308b..174283c909a 100644 --- a/services/idp/cmd/idp/main.go +++ b/services/idp/cmd/idp/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/idp/pkg/command" "github.com/owncloud/ocis/v2/services/idp/pkg/config/defaults" ) diff --git a/services/nats/cmd/nats/main.go b/services/nats/cmd/nats/main.go index 238cd5f6427..4b5803ac78c 100644 --- a/services/nats/cmd/nats/main.go +++ b/services/nats/cmd/nats/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/nats/pkg/command" "github.com/owncloud/ocis/v2/services/nats/pkg/config/defaults" ) diff --git a/services/notifications/cmd/notifications/main.go b/services/notifications/cmd/notifications/main.go index 0d596381211..5d5752af388 100644 --- a/services/notifications/cmd/notifications/main.go +++ b/services/notifications/cmd/notifications/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/notifications/pkg/command" "github.com/owncloud/ocis/v2/services/notifications/pkg/config/defaults" ) diff --git a/services/ocdav/cmd/ocdav/main.go b/services/ocdav/cmd/ocdav/main.go index 38f93f5a0de..9875027bdb5 100644 --- a/services/ocdav/cmd/ocdav/main.go +++ b/services/ocdav/cmd/ocdav/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/ocdav/pkg/command" "github.com/owncloud/ocis/v2/services/ocdav/pkg/config/defaults" ) diff --git a/services/ocs/cmd/ocs/main.go b/services/ocs/cmd/ocs/main.go index 25151dfc4f7..a2b9021ead9 100644 --- a/services/ocs/cmd/ocs/main.go +++ b/services/ocs/cmd/ocs/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/ocs/pkg/command" "github.com/owncloud/ocis/v2/services/ocs/pkg/config/defaults" ) diff --git a/services/proxy/cmd/proxy/main.go b/services/proxy/cmd/proxy/main.go index a0cf7844811..7db75b5de08 100644 --- a/services/proxy/cmd/proxy/main.go +++ b/services/proxy/cmd/proxy/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/proxy/pkg/command" "github.com/owncloud/ocis/v2/services/proxy/pkg/config/defaults" ) diff --git a/services/search/cmd/search/main.go b/services/search/cmd/search/main.go index 434161fdd52..70103e7bf00 100644 --- a/services/search/cmd/search/main.go +++ b/services/search/cmd/search/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/search/pkg/command" "github.com/owncloud/ocis/v2/services/search/pkg/config/defaults" ) diff --git a/services/settings/cmd/settings/main.go b/services/settings/cmd/settings/main.go index 7fe28a9ebe4..1e21338dd80 100644 --- a/services/settings/cmd/settings/main.go +++ b/services/settings/cmd/settings/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/settings/pkg/command" "github.com/owncloud/ocis/v2/services/settings/pkg/config/defaults" ) diff --git a/services/sharing/cmd/sharing/main.go b/services/sharing/cmd/sharing/main.go index 8282d96b70c..54e0996e3fd 100644 --- a/services/sharing/cmd/sharing/main.go +++ b/services/sharing/cmd/sharing/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/sharing/pkg/command" "github.com/owncloud/ocis/v2/services/sharing/pkg/config/defaults" ) diff --git a/services/storage-publiclink/cmd/storage-publiclink/main.go b/services/storage-publiclink/cmd/storage-publiclink/main.go index c15fe2ae92a..6d2415a0070 100644 --- a/services/storage-publiclink/cmd/storage-publiclink/main.go +++ b/services/storage-publiclink/cmd/storage-publiclink/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/command" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/config/defaults" ) diff --git a/services/storage-shares/cmd/storage-shares/main.go b/services/storage-shares/cmd/storage-shares/main.go index f59275418bd..8a8f9336beb 100644 --- a/services/storage-shares/cmd/storage-shares/main.go +++ b/services/storage-shares/cmd/storage-shares/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/command" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/config/defaults" ) diff --git a/services/storage-system/cmd/storage-system/main.go b/services/storage-system/cmd/storage-system/main.go index 34ecd75820c..d9242ea0571 100644 --- a/services/storage-system/cmd/storage-system/main.go +++ b/services/storage-system/cmd/storage-system/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/storage-system/pkg/command" "github.com/owncloud/ocis/v2/services/storage-system/pkg/config/defaults" ) diff --git a/services/storage-users/cmd/storage-users/main.go b/services/storage-users/cmd/storage-users/main.go index 5d0ca3aeb77..c3c7bc7e3f0 100644 --- a/services/storage-users/cmd/storage-users/main.go +++ b/services/storage-users/cmd/storage-users/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/storage-users/pkg/command" "github.com/owncloud/ocis/v2/services/storage-users/pkg/config/defaults" ) diff --git a/services/store/cmd/store/main.go b/services/store/cmd/store/main.go index 7dfbc496a23..ecf42e81938 100644 --- a/services/store/cmd/store/main.go +++ b/services/store/cmd/store/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/store/pkg/command" "github.com/owncloud/ocis/v2/services/store/pkg/config/defaults" ) diff --git a/services/thumbnails/cmd/thumbnails/main.go b/services/thumbnails/cmd/thumbnails/main.go index 86bf69d2bd0..f0a86f58bf2 100644 --- a/services/thumbnails/cmd/thumbnails/main.go +++ b/services/thumbnails/cmd/thumbnails/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/command" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/config/defaults" ) diff --git a/services/users/cmd/user/main.go b/services/users/cmd/user/main.go index 2655b24aa10..cae358d3c0b 100644 --- a/services/users/cmd/user/main.go +++ b/services/users/cmd/user/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/users/pkg/command" "github.com/owncloud/ocis/v2/services/users/pkg/config/defaults" ) diff --git a/services/web/cmd/web/main.go b/services/web/cmd/web/main.go index d2403a3a689..9974c37fc9a 100644 --- a/services/web/cmd/web/main.go +++ b/services/web/cmd/web/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/web/pkg/command" "github.com/owncloud/ocis/v2/services/web/pkg/config/defaults" ) diff --git a/services/webdav/cmd/webdav/main.go b/services/webdav/cmd/webdav/main.go index 3c811d4011d..84449ec2e3e 100644 --- a/services/webdav/cmd/webdav/main.go +++ b/services/webdav/cmd/webdav/main.go @@ -3,7 +3,6 @@ package main import ( "os" - _ "github.com/owncloud/ocis/v2/ocis-pkg/log/gomicro" "github.com/owncloud/ocis/v2/services/webdav/pkg/command" "github.com/owncloud/ocis/v2/services/webdav/pkg/config/defaults" ) From 83bbabac3c8bf922c6682a05d311c7e24d100330 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Fri, 8 Jul 2022 07:55:11 +0200 Subject: [PATCH 3/3] remove leftover setMicroLogger from runtime --- ocis/pkg/runtime/service/service.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index dc5e76bfdbd..2cc5a3e3db7 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -15,7 +15,6 @@ import ( "github.com/owncloud/ocis/v2/ocis-pkg/shared" - mzlog "github.com/go-micro/plugins/v4/logger/zerolog" "github.com/mohae/deepcopy" "github.com/olekukonko/tablewriter" @@ -50,9 +49,7 @@ import ( users "github.com/owncloud/ocis/v2/services/users/pkg/command" web "github.com/owncloud/ocis/v2/services/web/pkg/command" webdav "github.com/owncloud/ocis/v2/services/webdav/pkg/command" - "github.com/rs/zerolog" "github.com/thejerf/suture/v4" - "go-micro.dev/v4/logger" ) var ( @@ -157,8 +154,6 @@ func Start(o ...Option) error { halt := make(chan os.Signal, 1) signal.Notify(halt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) - setMicroLogger() - // tolerance controls backoff cycles from the supervisor. tolerance := 5 totalBackoff := 0 @@ -301,17 +296,3 @@ func trap(s *Service, halt chan os.Signal) { s.Log.Debug().Str("service", "runtime service").Msgf("terminating with signal: %v", s) os.Exit(0) } - -// for logging reasons we don't want the same logging level on both oCIS and micro. As a framework builder we do not -// want to expose to the end user the internal framework logs unless explicitly specified. -func setMicroLogger() { - if os.Getenv("MICRO_LOG_LEVEL") == "" { - _ = os.Setenv("MICRO_LOG_LEVEL", "error") - } - - lev, err := zerolog.ParseLevel(os.Getenv("MICRO_LOG_LEVEL")) - if err != nil { - lev = zerolog.ErrorLevel - } - logger.DefaultLogger = mzlog.NewLogger(logger.WithLevel(logger.Level(lev))) -}