config: add logger to options

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-12-07 19:27:08 +03:00
parent c7ed807129
commit 8fd745eab0
1 changed files with 13 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"github.com/unistack-org/micro/v3/codec"
"github.com/unistack-org/micro/v3/logger"
)
type Options struct {
@ -15,6 +16,8 @@ type Options struct {
Struct interface{}
// struct tag name
StructTag string
// logger that will be used
Logger logger.Logger
// codec that used for load/save
Codec codec.Codec
// for alternative data
@ -58,8 +61,6 @@ func AfterSave(fn ...func(context.Context, Config) error) Option {
}
}
func Context(ctx context.Context) Option {
return func(o *Options) {
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 {
return func(o *Options) {
o.Struct = v