]> git.giacomolli.uk - onechat/blobdiff - daemon.go
Log Telegram outages once in plain words
[onechat] / daemon.go
index 3a950da5c91af35f2dc622837f45020f0a89f352..f7ed315745ab37033573a0f6dc122cf6abd304ab 100644 (file)
--- 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()
+}