diff --git a/log/log.go b/log/log.go index 64d47a1121caebd5345699adf4e5f5da29872698..d027e383f77d50f2dae232d54d56d4cb3ddb6ef2 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