From 97f17918066115bebfbce4d6b6ad7158eca651e8 Mon Sep 17 00:00:00 2001 From: ko_oler <kooler89@gmail.com> Date: Thu, 8 Feb 2024 18:45:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B2?= =?UTF-8?q?=20EntryToPB=20=D0=B8=20EntryFromPB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- log/log.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/log/log.go b/log/log.go index 64d47a11..d027e383 100644 --- a/log/log.go +++ b/log/log.go @@ -81,8 +81,6 @@ func EntryFromPB(request *pb.LogEntry) *Entry { Category: request.Category, Component: request.Component, Event: request.Event, - Attr: request.Attr, // todo: как с этим работать? - Tags: request.Tags, } if request.ObjectId != "" { @@ -91,6 +89,12 @@ func EntryFromPB(request *pb.LogEntry) *Entry { if request.CallerId != "" { logEntry.CallerID, _ = id.Parse(request.CallerId) } + if request.Attr != nil { + logEntry.Attr = request.Attr // todo: как с этим работать? + } + if request.Tags != nil { + logEntry.Tags = request.Tags + } return logEntry } @@ -104,8 +108,12 @@ func (e *Entry) ToMap() map[string]any { "category": e.Category, "component": e.Component, "event": e.Event, - "object_id": e.ObjectID.String(), - "caller_id": e.CallerID.String(), + } + if e.ObjectID != nil { + res["object_id"] = e.ObjectID.String() + } + if e.CallerID != nil { + res["caller_id"] = e.CallerID.String() } if e.Attr != nil { res["attr"] = e.Attr -- GitLab