Reduce log spam
This commit is contained in:
10
candidate.go
10
candidate.go
@@ -72,7 +72,7 @@ func NewCandidate(numVoters int, signingKey string) *Candidate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.forceState != StateUndefined {
|
if c.forceState != StateUndefined {
|
||||||
log.Printf("[elect] state forced to %s", StateName[c.forceState])
|
c.log("state forced to %s", StateName[c.forceState])
|
||||||
c.state = c.forceState
|
c.state = c.forceState
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,8 +205,8 @@ func (c *Candidate) elect(v *vote) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf(
|
c.log(
|
||||||
"[elect] transitioning %s -> %s (no=%d yes=%d min_yes=%d)",
|
"transitioning %s -> %s (no=%d yes=%d min_yes=%d)",
|
||||||
StateName[c.state],
|
StateName[c.state],
|
||||||
StateName[state],
|
StateName[state],
|
||||||
no,
|
no,
|
||||||
@@ -287,6 +287,10 @@ func (c *Candidate) loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Candidate) log(format string, args ...any) {
|
||||||
|
log.Printf("[candidate] "+format, args...)
|
||||||
|
}
|
||||||
|
|
||||||
func getForceState() CandidateState {
|
func getForceState() CandidateState {
|
||||||
switch *electForceState {
|
switch *electForceState {
|
||||||
case "":
|
case "":
|
||||||
|
|||||||
4
voter.go
4
voter.go
@@ -118,7 +118,7 @@ func (v *Voter) sendVote() {
|
|||||||
SetBody(js).
|
SetBody(js).
|
||||||
Post("")
|
Post("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("vote response: %s", err)
|
log.Printf("error: %s", err)
|
||||||
|
|
||||||
v.vote.NumPollsSinceChange = 0
|
v.vote.NumPollsSinceChange = 0
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ func (v *Voter) sendVote() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if resp.IsError() {
|
if resp.IsError() {
|
||||||
v.log("response: [%d] %s\n%s", resp.StatusCode(), resp.Status(), resp.String())
|
v.log("response: %d", resp.StatusCode())
|
||||||
|
|
||||||
v.vote.NumPollsSinceChange = 0
|
v.vote.NumPollsSinceChange = 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user