mirror of
https://github.com/go-micro/go-micro.git
synced 2025-11-29 21:47:44 +02:00
feat(logger): add logger option to all micro components (override DefaultLogger) closes #2556 (#2559)
* feat(logger): add logger option to all components * fix: refactor api/rpc.go * fix: refactor api/stream.go * fix: api/options.go comment * fix(logger): do not use logger.Helper internally * fix(logger): fix comments * fix(logger): use level.Enabled method * fix: rename mlogger to log * fix: run go fmt * fix: log level * fix: factories Co-authored-by: Mohamed MHAMDI <mmhamdi@hubside.com> Co-authored-by: Davincible <david.brouwer.99@gmail.com>
This commit is contained in:
12
cache/options.go
vendored
12
cache/options.go
vendored
@@ -3,6 +3,8 @@ package cache
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"go-micro.dev/v4/logger"
|
||||
)
|
||||
|
||||
// Options represents the options for the cache.
|
||||
@@ -13,6 +15,8 @@ type Options struct {
|
||||
Address string
|
||||
// Context should contain all implementation specific options, using context.WithValue.
|
||||
Context context.Context
|
||||
// Logger is the be used logger
|
||||
Logger logger.Logger
|
||||
}
|
||||
|
||||
// Option manipulates the Options passed.
|
||||
@@ -46,11 +50,19 @@ func WithContext(c context.Context) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithLogger sets underline logger
|
||||
func WithLogger(l logger.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = l
|
||||
}
|
||||
}
|
||||
|
||||
// NewOptions returns a new options struct.
|
||||
func NewOptions(opts ...Option) Options {
|
||||
options := Options{
|
||||
Expiration: DefaultExpiration,
|
||||
Items: make(map[string]Item),
|
||||
Logger: logger.DefaultLogger,
|
||||
}
|
||||
|
||||
for _, o := range opts {
|
||||
|
||||
Reference in New Issue
Block a user