Skip to content

Commit

Permalink
Fixup previous commit to avoid using blank imports
Browse files Browse the repository at this point in the history
  • Loading branch information
rhafer committed Jul 7, 2022
1 parent 33f6ee3 commit 875ad91
Show file tree
Hide file tree
Showing 33 changed files with 45 additions and 66 deletions.
33 changes: 0 additions & 33 deletions ocis-pkg/log/gomicro/log.go

This file was deleted.

27 changes: 26 additions & 1 deletion ocis-pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 19 additions & 2 deletions ocis/pkg/runtime/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)))
}
1 change: 0 additions & 1 deletion services/app-provider/cmd/app-provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/app-registry/cmd/app-registry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/audit/cmd/audit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/auth-basic/cmd/auth-basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/auth-bearer/cmd/auth-bearer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/auth-machine/cmd/auth-machine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/frontend/cmd/frontend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/gateway/cmd/gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/graph-explorer/cmd/graph-explorer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/graph/cmd/graph/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/groups/cmd/groups/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/idm/cmd/idm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/idp/cmd/idp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/nats/cmd/nats/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/notifications/cmd/notifications/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/ocdav/cmd/ocdav/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/ocs/cmd/ocs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/proxy/cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/search/cmd/search/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/settings/cmd/settings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/sharing/cmd/sharing/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/storage-publiclink/cmd/storage-publiclink/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/storage-shares/cmd/storage-shares/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/storage-system/cmd/storage-system/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/storage-users/cmd/storage-users/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/store/cmd/store/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/thumbnails/cmd/thumbnails/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/users/cmd/user/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/web/cmd/web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 0 additions & 1 deletion services/webdav/cmd/webdav/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down

0 comments on commit 875ad91

Please sign in to comment.