X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/459656ed8c15847d325f07758e4a775935411c3d..1e2df788bbb17653a6df44acd41da2edb109d403:/daemon.go diff --git a/daemon.go b/daemon.go index 3a950da..f7ed315 100644 --- a/daemon.go +++ b/daemon.go @@ -420,3 +420,13 @@ func daemonRunRequest(l *TurnLoop, whatsapp *WhatsApp, request SocketRequest, an return fmt.Errorf("unknown request %q", request.Type) } } + +// durationText returns d for a log line: rounded to the second, or to the +// millisecond when it is shorter than a second. +func durationText(d time.Duration) string { + if d < time.Second { + return d.Round(time.Millisecond).String() + } + + return d.Round(time.Second).String() +}