pass around the correct logger to the services
Also did some minor refactoring to make the code similar to the other services. Implements one task of owncloud/product#86 Signed-off-by: David Christofas <dchristofas@owncloud.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package grpc
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-accounts/pkg/config"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
)
|
||||
@@ -18,6 +19,7 @@ type Options struct {
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Namespace string
|
||||
Flags []cli.Flag
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
@@ -72,3 +74,10 @@ func Namespace(val string) Option {
|
||||
o.Namespace = val
|
||||
}
|
||||
}
|
||||
|
||||
// Flags provides a function to set the flags option.
|
||||
func Flags(val []cli.Flag) Option {
|
||||
return func(o *Options) {
|
||||
o.Flags = append(o.Flags, val...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,13 @@ func NewService(opts ...Option) grpc.Service {
|
||||
grpc.Address(options.Address),
|
||||
grpc.Namespace(options.Namespace),
|
||||
grpc.Logger(options.Logger),
|
||||
grpc.Flags(options.Flags...),
|
||||
)
|
||||
|
||||
var hdlr *svc.Service
|
||||
var err error
|
||||
|
||||
if hdlr, err = svc.New(options.Config); err != nil {
|
||||
if hdlr, err = svc.New(svc.Logger(options.Logger), svc.Config(options.Config)); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not initialize service handler")
|
||||
}
|
||||
if err = proto.RegisterAccountsServiceHandler(service.Server(), hdlr); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user