From 74ca3795484f632cd254e695ef850f2275efb426 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 20 Jan 2022 01:10:11 +0300 Subject: [PATCH] logger: update for latest micro Signed-off-by: Vasiliy Tolstov --- service.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/service.go b/service.go index 7a80b6d..6ddf2c6 100644 --- a/service.go +++ b/service.go @@ -18,7 +18,19 @@ type serviceLogger struct { service string client pbmicro.LoggerServiceClient 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 { @@ -49,12 +61,9 @@ func (l *serviceLogger) Init(opts ...logger.Option) error { return nil } -func (l *serviceLogger) Fields(fields map[string]interface{}) logger.Logger { - nl := &serviceLogger{opts: l.opts, client: l.client, store: l.store} - nl.fields = make(map[string]interface{}, len(fields)) - for k, v := range fields { - nl.fields[k] = v - } +func (l *serviceLogger) Fields(fields ...interface{}) logger.Logger { + nl := &serviceLogger{fields: l.fields, service: l.service, opts: l.opts, client: l.client, store: l.store} + nl.fields = append(nl.fields, fields...) return nl }