diff --git a/log/log.go b/log/log.go index d95ecbed0e12372a9d53f7c367144df112c21e73..64d47a1121caebd5345699adf4e5f5da29872698 100644 --- a/log/log.go +++ b/log/log.go @@ -59,18 +59,21 @@ func EntryToPB(entry *Entry) *pb.LogEntry { Category: entry.Category, Component: entry.Component, Event: entry.Event, - ObjectId: entry.ObjectID.String(), - CallerId: entry.CallerID.String(), Attr: nil, //implement Tags: entry.Tags, } + if entry.ObjectID != nil { + logEntry.ObjectId = entry.ObjectID.String() + } + if entry.CallerID != nil { + logEntry.CallerId = entry.CallerID.String() + } + return logEntry } func EntryFromPB(request *pb.LogEntry) *Entry { - objectID, _ := id.Parse(request.ObjectId) - callerID, _ := id.Parse(request.CallerId) - return &Entry{ + logEntry := &Entry{ ID: request.Id, Timestamp: request.Timestamp.AsTime(), LogLevel: Level(request.Level), @@ -78,11 +81,18 @@ func EntryFromPB(request *pb.LogEntry) *Entry { Category: request.Category, Component: request.Component, Event: request.Event, - ObjectID: objectID, - CallerID: callerID, Attr: request.Attr, // todo: как с этим работать? Tags: request.Tags, } + + if request.ObjectId != "" { + logEntry.ObjectID, _ = id.Parse(request.ObjectId) + } + if request.CallerId != "" { + logEntry.CallerID, _ = id.Parse(request.CallerId) + } + + return logEntry } func (e *Entry) ToMap() map[string]any {