mirror of
https://github.com/nabbar/golib.git
synced 2025-12-24 11:51:02 +08:00
Fix issue #107
This commit is contained in:
@@ -35,16 +35,16 @@ func NewFields() Fields {
|
||||
return make(Fields)
|
||||
}
|
||||
|
||||
func (f Fields) new() map[string]interface{} {
|
||||
return make(map[string]interface{}, 0)
|
||||
}
|
||||
|
||||
func (f Fields) clone() map[string]interface{} {
|
||||
res := make(map[string]interface{}, 0)
|
||||
|
||||
if len(f) > 0 {
|
||||
return f
|
||||
for k, v := range f {
|
||||
res[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
return f.new()
|
||||
return res
|
||||
}
|
||||
|
||||
func (f Fields) Add(key string, val interface{}) Fields {
|
||||
@@ -84,7 +84,7 @@ func (f Fields) Merge(other Fields) Fields {
|
||||
}
|
||||
|
||||
func (f Fields) Clean(keys ...string) Fields {
|
||||
res := f.new()
|
||||
res := make(map[string]interface{}, 0)
|
||||
|
||||
if len(keys) > 0 {
|
||||
f.Map(func(key string, val interface{}) interface{} {
|
||||
|
||||
@@ -125,7 +125,7 @@ func New() Logger {
|
||||
lvl.Store(InfoLevel)
|
||||
|
||||
return &logger{
|
||||
m: sync.Mutex{},
|
||||
m: &sync.Mutex{},
|
||||
l: lvl,
|
||||
o: new(atomic.Value),
|
||||
s: new(atomic.Value),
|
||||
|
||||
@@ -55,7 +55,7 @@ var _selfPackage = path.Base(reflect.TypeOf(logger{}).PkgPath())
|
||||
type logger struct {
|
||||
x context.Context
|
||||
n context.CancelFunc
|
||||
m sync.Mutex
|
||||
m sync.Locker
|
||||
l *atomic.Value //current level set for this logger
|
||||
o *atomic.Value //options
|
||||
s *atomic.Value //logrus logger
|
||||
@@ -144,7 +144,7 @@ func (l *logger) Clone(ctx context.Context) (Logger, error) {
|
||||
c := &logger{
|
||||
x: nil,
|
||||
n: nil,
|
||||
m: sync.Mutex{},
|
||||
m: &sync.Mutex{},
|
||||
l: new(atomic.Value),
|
||||
o: new(atomic.Value),
|
||||
s: new(atomic.Value),
|
||||
|
||||
Reference in New Issue
Block a user