func printTableEntry()

in collector/collector.go [488:543]


func printTableEntry(
	r report,
	targetHost string,
	targetLocation string,
	srcPort layers.TCPPort,
	foreground bool,
	logger *log.Logger,
) {
	var twoWay, oneWay zapcore.Field

	color.Set(color.FgHiYellow)
	defer color.Unset()

	timedOut := "no"
	if r.timedOut {
		timedOut = "yes"
	}
	if foreground {
		fmt.Printf("%-51s|", targetHost+"("+strconv.Itoa(int(srcPort))+")")
		fmt.Printf("%-26s|%3s", " "+targetLocation, "")
	}

	if r.latency2Way == 0 {
		twoWay = zap.String("2-way", "-")
		oneWay = zap.String("1-way", "-")
		if foreground {
			fmt.Printf("%4s %11s%8s%5s%s\n", "-", "-", "|", "", timedOut)
		}
	} else {
		twoWay = zap.Float64("2-way", float64(r.latency2Way/1e5)/10.0)
		// Ignore 1-way when echoing an external server or when estimated value is smaller than a threshold
		if r.latency1Way == -1 || r.latency1Way < 10*time.Nanosecond {
			if foreground {
				fmt.Printf("%5.1f %11s%7s%5s%s\n", float32(r.latency2Way/1e5)/10.0,
					"N/A", "|", "", timedOut)
			}
			oneWay = zap.String("1-way", "N/A")
		} else {
			if foreground {
				fmt.Printf("%5.1f %11.1f%7s%5s%s\n", float32(r.latency2Way/1e5)/10.0,
					float32(r.latency1Way/1e5)/10.0, "|", "", timedOut)
			}
			oneWay = zap.Float64("1-way", float64(r.latency1Way/1e5)/10.0/10.0)
		}
	}

	if !foreground {
		logger.Info("Result",
			zap.String("target", targetHost),
			zap.String("target_location", targetLocation),
			zap.Any("source_port", srcPort),
			twoWay,
			oneWay,
			zap.String("timed_out", timedOut))
	}
}