in pcap-cli/internal/transformer/flow_mutex.go [117:166]
func (fm *flowMutex) log(
ctx context.Context,
serial *uint64,
flowID *uint64,
tcpFlags *uint8,
seq, ack *uint32,
timestamp *time.Time,
message *string,
) {
if !fm.Debug {
return
}
json := gabs.New()
id := ctx.Value(ContextID)
logName := ctx.Value(ContextLogName)
pcap, _ := json.Object("pcap")
pcap.Set(id, "id")
pcap.Set(logName, "ctx")
serialStr := strconv.FormatUint(*serial, 10)
pcap.Set(serialStr, "num")
flowIDstr := strconv.FormatUint(*flowID, 10)
json.Set(flowIDstr, "flow")
tcpJSON, _ := json.Object("tcp")
tcpJSON.Set(tcpFlagsStr[*tcpFlags], "flags")
tcpJSON.Set(*seq, "seq")
tcpJSON.Set(*ack, "ack")
timestampJSON, _ := json.Object("timestamp")
timestampJSON.Set(timestamp.Unix(), "seconds")
timestampJSON.Set(timestamp.Nanosecond(), "nanos")
labels, _ := json.Object("logging.googleapis.com/labels")
labels.Set("pcap", "run.googleapis.com/tool")
labels.Set(id, "run.googleapis.com/pcap/id")
labels.Set(logName, "run.googleapis.com/pcap/name")
operation, _ := json.Object("logging.googleapis.com/operation")
operation.Set(sf.Format("{0}/debug", logName), "producer")
operation.Set(sf.Format("{0}/flow/{1}/debug", id, flowIDstr), "id")
json.Set(sf.Format("#:{0} | flow:{1} | {2}", serialStr, flowIDstr, *message), "message")
io.WriteString(os.Stderr, json.String()+"\n")
}