Skip to content

Commit

Permalink
init time logger for eosgrpc storage driver
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Nov 3, 2023
1 parent 27abf8b commit c3a288a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions pkg/eosclient/eosgrpc/eosgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ import (
"github.com/cs3org/reva/pkg/eosclient"
erpc "github.com/cs3org/reva/pkg/eosclient/eosgrpc/eos_grpc"
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/logger"
"github.com/cs3org/reva/pkg/storage/utils/acl"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
Expand Down Expand Up @@ -138,8 +138,7 @@ type Client struct {
}

// Create and connect a grpc eos Client.
func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) {
log := appctx.GetLogger(ctx)
func newgrpc(ctx context.Context, log *zerolog.Logger, opt *Options) (erpc.EosClient, error) {
log.Info().Str("Setting up GRPC towards ", "'"+opt.GrpcURI+"'").Msg("")

conn, err := grpc.Dial(opt.GrpcURI, grpc.WithTransportCredentials(insecure.NewCredentials()))
Expand Down Expand Up @@ -168,18 +167,18 @@ func newgrpc(ctx context.Context, opt *Options) (erpc.EosClient, error) {
}

// New creates a new client with the given options.
func New(opt *Options, httpOpts *HTTPOptions) (*Client, error) {
tlog := logger.New().With().Int("pid", os.Getpid()).Logger()
tlog.Debug().Str("Creating new eosgrpc client. opt: ", "'"+fmt.Sprintf("%#v", opt)+"' ").Msg("")
func New(ctx context.Context, opt *Options, httpOpts *HTTPOptions) (*Client, error) {
log := appctx.GetLogger(ctx)

log.Debug().Str("Creating new eosgrpc client. opt: ", "'"+fmt.Sprintf("%#v", opt)+"' ").Msg("")

opt.init()
httpcl, err := NewEOSHTTPClient(httpOpts)
if err != nil {
return nil, err
}

tctx := appctx.WithLogger(context.Background(), &tlog)
cl, err := newgrpc(tctx, opt)
cl, err := newgrpc(ctx, log, opt)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func NewEOSFS(ctx context.Context, c *Config) (storage.FS, error) {
ClientCAFiles: c.ClientCAFiles,
Authkey: c.HTTPSAuthkey,
}
eosClient, err = eosgrpc.New(eosClientOpts, eosHTTPOpts)
eosClient, err = eosgrpc.New(ctx, eosClientOpts, eosHTTPOpts)
} else {
eosClientOpts := &eosbinary.Options{
XrdcopyBinary: c.XrdcopyBinary,
Expand Down

0 comments on commit c3a288a

Please sign in to comment.