logger updates #57

Merged
vtolstov merged 2 commits from logger into master 2022-01-20 01:11:40 +03:00
Showing only changes of commit 74ca379548 - Show all commits

View File

@ -18,7 +18,19 @@ type serviceLogger struct {
service string service string
client pbmicro.LoggerServiceClient client pbmicro.LoggerServiceClient
store store.Store store store.Store
fields map[string]interface{} fields []interface{}
}
func (l *serviceLogger) Clone(opts ...logger.Option) logger.Logger {
nl := &serviceLogger{service: l.service, store: l.store, client: l.client, opts: l.opts}
for _, o := range opts {
o(&nl.opts)
}
return nl
}
func (l *serviceLogger) Level(lvl logger.Level) {
l.opts.Level = lvl
} }
func (l *serviceLogger) Init(opts ...logger.Option) error { func (l *serviceLogger) Init(opts ...logger.Option) error {
@ -49,12 +61,9 @@ func (l *serviceLogger) Init(opts ...logger.Option) error {
return nil return nil
} }
func (l *serviceLogger) Fields(fields map[string]interface{}) logger.Logger { func (l *serviceLogger) Fields(fields ...interface{}) logger.Logger {
nl := &serviceLogger{opts: l.opts, client: l.client, store: l.store} nl := &serviceLogger{fields: l.fields, service: l.service, opts: l.opts, client: l.client, store: l.store}
nl.fields = make(map[string]interface{}, len(fields)) nl.fields = append(nl.fields, fields...)
for k, v := range fields {
nl.fields[k] = v
}
return nl return nl
} }