fix(connections): log what was actually sent, and rename the section
Two answers to "can people debug this when it does not work".
They could not. A custom UDP row logged "sent 18 bytes to 127.0.0.1:12000"
and nothing about the message — which is a template the operator wrote, so
the byte count says nothing about whether the substitution came out as they
meant. The payload is now in the line, with the trigger that fired it, for
custom rows only: an ADIF record or a binary WSJT frame on every QSO would
bury the log rather than fill it.
Worse was the silent case. A template that is a single placeholder the trigger
does not carry — {freq} on a band change — renders empty, sends nothing, and
looked exactly like a row that had never fired. It now says so, throttled per
row, and points at the field list.
And a password in a URL is redacted before it reaches the file. Storing
http://admin:secret@switch/ as typed was a deliberate choice for LAN gear;
writing it into a log that gets sent to whoever is helping is a different
choice, and was never made.
The Settings section is "Connections" rather than "UDP integrations", since it
has not been UDP-only since the URL transport landed. The log prefix stays
"udp:" on purpose — renaming it would orphan every log an operator has already
sent and every note anyone has written against it.
This commit is contained in:
@@ -132,6 +132,34 @@ func (m *Manager) EmitLoggedQSOWSJT(q LoggedQSO, adifRec string) {
|
||||
}
|
||||
}
|
||||
|
||||
// sentPreview appends what was actually sent, for the rows where that is worth
|
||||
// reading.
|
||||
//
|
||||
// Custom rows only, and deliberately: their payload is a template the operator
|
||||
// wrote, and "sent 18 bytes" tells them nothing about whether the substitution
|
||||
// came out as they meant. The ADIF and WSJT-X rows carry a whole record or a
|
||||
// binary frame, and dumping either into the log on every QSO would bury it.
|
||||
//
|
||||
// The trigger is named too — a row that fires on the wrong moment looks exactly
|
||||
// like a row that does not fire.
|
||||
func sentPreview(c Config, payload []byte) string {
|
||||
if c.ServiceType != ServiceCustom {
|
||||
return ""
|
||||
}
|
||||
const maxShown = 200
|
||||
s := string(payload)
|
||||
if len(s) > maxShown {
|
||||
s = s[:maxShown] + "…"
|
||||
}
|
||||
// %q below already renders a carriage return as \r rather than breaking the
|
||||
// log line in two — and it is the line ending the operator chose, so it has
|
||||
// to be visible. Escaping it by hand first would double every backslash.
|
||||
if c.Trigger != "" {
|
||||
return fmt.Sprintf(" on %s: %q", c.Trigger, s)
|
||||
}
|
||||
return fmt.Sprintf(": %q", s)
|
||||
}
|
||||
|
||||
// sendTo resolves the row's destination (host:port) and fires one datagram.
|
||||
//
|
||||
// A successful send is logged, not just a failure. UDP has no delivery report:
|
||||
@@ -154,5 +182,6 @@ func (m *Manager) sendTo(c Config, payload []byte) {
|
||||
applog.Printf("udp: [%s] outbound send to %s failed: %v", c.Name, dst, err)
|
||||
return
|
||||
}
|
||||
applog.Printf("udp: [%s] sent %d bytes to %s (%s)", c.Name, len(payload), dst, c.ServiceType)
|
||||
applog.Printf("udp: [%s] sent %d bytes to %s (%s)%s",
|
||||
c.Name, len(payload), dst, c.ServiceType, sentPreview(c, payload))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user