From 18bcc4fe73bd8245cde001c939b400693a0d9410 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Wed, 17 Aug 2022 22:07:35 -0400 Subject: [Feature] Add TCP information (RTT and Cwnd) to Logging This patch adds support for logging the underlying RTT and Cwnd of the TCP connection used when doing probes. More work to follow in order to add support for this information on Windows and Darwin. --- datalogger/logger.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'datalogger') diff --git a/datalogger/logger.go b/datalogger/logger.go index 1a4cd20..6236b59 100644 --- a/datalogger/logger.go +++ b/datalogger/logger.go @@ -66,19 +66,20 @@ func doCustomFormatting(value reflect.Value, tag reflect.StructTag) (string, err } formatMethodArgument, success := tag.Lookup("FormatterArgument") if !success { - return "", fmt.Errorf("Could not find the formatter name") + formatMethodArgument = "" } formatMethod := value.MethodByName(formatMethodName) if formatMethod == reflect.ValueOf(0) { return "", fmt.Errorf("Type %v does not support a method named %v", value.Type(), formatMethodName) } - - formatMethodArgumentUsable := make([]reflect.Value, 1) - formatMethodArgumentUsable[0] = reflect.ValueOf(formatMethodArgument) + var formatMethodArgumentUsable []reflect.Value = make([]reflect.Value, 0) + if formatMethodArgument != "" { + formatMethodArgumentUsable = append(formatMethodArgumentUsable, reflect.ValueOf(formatMethodArgument)) + } result := formatMethod.Call(formatMethodArgumentUsable) if len(result) == 1 { - return result[0].String(), nil + return fmt.Sprintf("%v", result[0]), nil } return "", fmt.Errorf("Too many results returned by the format method's invocation.") } -- cgit v1.2.3