1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-11-06 08:39:09 +02:00

Bugfix/logging (#346)

* Fixed inability to pass custom ID to th runtime logger

* Removed UUID module

* Removed redundant check
This commit is contained in:
Tim Voronov
2019-08-02 23:28:25 -04:00
committed by GitHub
parent 2ba68ebf00
commit 2997a9b264
5 changed files with 18 additions and 19 deletions

View File

@@ -13,7 +13,7 @@ import (
type (
Options struct {
params map[string]core.Value
logging *logging.Options
logging logging.Options
}
Option func(*Options)
@@ -22,7 +22,7 @@ type (
func NewOptions(setters []Option) *Options {
opts := &Options{
params: make(map[string]core.Value),
logging: &logging.Options{
logging: logging.Options{
Writer: os.Stdout,
Level: logging.ErrorLevel,
},
@@ -61,6 +61,12 @@ func WithLogLevel(lvl logging.Level) Option {
}
}
func WithLogFields(fields map[string]interface{}) Option {
return func(options *Options) {
options.logging.Fields = fields
}
}
func (opts *Options) WithContext(parent context.Context) context.Context {
ctx := core.ParamsWith(parent, opts.params)
ctx = logging.WithContext(ctx, opts.logging)