package logmower import ( "time" "go.mongodb.org/mongo-driver/bson" ) // when editing, also edit everything in this file! type mLog struct { HostInfo HostInfo File string Offset int64 // byte offset where log entry ends at Content string // TODO: ShipTime time.Time CollectTime time.Time StdErr bool Format string // F or P TODO: what does it mean? Is there a well-defined log format for cri-o? } const ( mongoKeyHostInfo = "host_info" mongoKeyId = "id" mongoKeyHostInfoId = mongoKeyHostInfo + "." + mongoKeyId mongoKeyFileBasename = "file" mongoKeyOffset = "offset" ) // not using marshal, since it is <0.1x performance func (l *mLog) toBson() bson.M { // DO NOT USE QUOTED STRINGS! Move them to const and use variable instead return bson.M{ mongoKeyHostInfo: bson.M{ mongoKeyId: l.HostInfo.id, "name": l.HostInfo.name, "arch": l.HostInfo.arch, }, mongoKeyFileBasename: l.File, mongoKeyOffset: l.Offset, "content": l.Content, "ship_time": l.ShipTime, "container_time": l.CollectTime, "stderr": l.StdErr, "format": l.Format, } }