config: add logger to options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
c7ed807129
commit
8fd745eab0
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/unistack-org/micro/v3/codec"
|
"github.com/unistack-org/micro/v3/codec"
|
||||||
|
"github.com/unistack-org/micro/v3/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
@ -15,6 +16,8 @@ type Options struct {
|
|||||||
Struct interface{}
|
Struct interface{}
|
||||||
// struct tag name
|
// struct tag name
|
||||||
StructTag string
|
StructTag string
|
||||||
|
// logger that will be used
|
||||||
|
Logger logger.Logger
|
||||||
// codec that used for load/save
|
// codec that used for load/save
|
||||||
Codec codec.Codec
|
Codec codec.Codec
|
||||||
// for alternative data
|
// for alternative data
|
||||||
@ -58,8 +61,6 @@ func AfterSave(fn ...func(context.Context, Config) error) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func Context(ctx context.Context) Option {
|
func Context(ctx context.Context) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Context = ctx
|
o.Context = ctx
|
||||||
@ -73,7 +74,13 @@ func Codec(c codec.Codec) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Struct
|
func Logger(l logger.Logger) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.Logger = l
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Struct used as config
|
||||||
func Struct(v interface{}) Option {
|
func Struct(v interface{}) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Struct = v
|
o.Struct = v
|
||||||
|
Loading…
Reference in New Issue
Block a user