chore(tci): cap the diagnostic logging per message type
The transmit meters are asked for four times a second while keyed, so logging every arrival would fill an evening's log — and a diagnostic that fills a log is one that gets switched off instead of read. Twenty of each is enough to tell an answer from a silence, which is all it is for.
This commit is contained in:
@@ -88,6 +88,8 @@ type TCIPanelState struct {
|
|||||||
// arrives alongside.
|
// arrives alongside.
|
||||||
type tciPanel struct {
|
type tciPanel struct {
|
||||||
st TCIPanelState
|
st TCIPanelState
|
||||||
|
// logged counts what has been written per message type — see handlePanel.
|
||||||
|
logged map[string]int
|
||||||
}
|
}
|
||||||
|
|
||||||
// handlePanel takes the messages the console cares about.
|
// handlePanel takes the messages the console cares about.
|
||||||
@@ -112,12 +114,21 @@ func (t *TCI) handlePanel(name string, get func(int) string, args string) bool {
|
|||||||
// this is our reading or its doing, and no amount of reasoning will.
|
// this is our reading or its doing, and no amount of reasoning will.
|
||||||
switch name {
|
switch name {
|
||||||
case "mute", "sql_enable", "sql_level", "tx_power", "tx_swr", "tune":
|
case "mute", "sql_enable", "sql_level", "tx_power", "tx_swr", "tune":
|
||||||
// Logged on arrival so an ANSWER can be told from a silence. The
|
// Logged on arrival so an ANSWER can be told from a SILENCE: the log
|
||||||
// transmit meters are asked for four times a second while keyed and the
|
// showed the transmit meters being asked for and nothing coming back,
|
||||||
// log showed only the asking, which proves nothing on its own: a reply
|
// which on its own proves nothing — a reply that arrived and failed to
|
||||||
// that arrived and failed to parse looks exactly like one that never
|
// parse leaves exactly the same trace as one that never came.
|
||||||
// came.
|
//
|
||||||
debugLog.Printf("TCI: %s:%s", name, args)
|
// Capped per message type. The meters are asked for four times a second
|
||||||
|
// while transmitting, and a diagnostic that fills an evening's log is
|
||||||
|
// one that gets switched off instead of read.
|
||||||
|
if t.panel.logged == nil {
|
||||||
|
t.panel.logged = map[string]int{}
|
||||||
|
}
|
||||||
|
if n := t.panel.logged[name]; n < 20 {
|
||||||
|
t.panel.logged[name] = n + 1
|
||||||
|
debugLog.Printf("TCI: %s:%s", name, args)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch name {
|
switch name {
|
||||||
case "protocol":
|
case "protocol":
|
||||||
|
|||||||
Reference in New Issue
Block a user