You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, fields in logger are commented out, however, it's useful to inherit logger, like in logrus, there is WithField(s) to create new logger
typeLoggerstruct {
mu sync.RWMutexhHandlerlevelLevel// TODO: Fields in logger are never used, we are using DebugF to pass temporary fields// which does not allow inherit fields from parent logger//fields Fieldschildrenmap[string][]*Loggersourceboolid*Identity
}
func (s*S) init() {
s.logger.AddStringField("f1", "v1")
}
func (s*S) Foo() {
s.logger.Info(1) // pkg=f1 struct=S f1=v1fLogger:=s.logger.WithFuncAuto() // add Func to field using runtime package, this have a much higher cost than given a string manuallyfLogger.Info(1) // pkg=f1 struct=S func=Foo f1=v1fLogger.WithField(dlog.Int("num", 2)).Info("mie") // pkg=f1 struct=S func=Foo f1=v1 num=2
}
There are some problems though
do we sort and merge duplicated fields, no
changes in the handlers, do we merge the slice of fields in logger, it's kind of a waste of space, no we pass to arguments,fields in logger are called cotnext, fields in log call site are called fields
The text was updated successfully, but these errors were encountered:
we didn't go with With syntax which either do a copy or create a new entry/event struct, we only have Add to add context in place, this problem should be solved after we figure out the correct way to deal with the tree of logger problem we created for ourselves ... #33#78
logging fields attached to logger is implemented in #90
Currently, fields in logger are commented out, however, it's useful to inherit logger, like in logrus, there is
WithField(s)
to create new loggerThere are some problems though
The text was updated successfully, but these errors were encountered: