Skip to content

Commit

Permalink
Circuits: consistent log formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jun 16, 2024
1 parent 0b52fd2 commit 477141e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/circuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ func (c *Circuit) updateMeters() error {
func (c *Circuit) Update(loadpoints []api.CircuitLoad) (err error) {
defer func() {
if c.maxPower != 0 && c.power > c.maxPower {
c.log.WARN.Printf("over power detected: %gW > %gW", c.power, c.maxPower)
c.log.WARN.Printf("over power detected: %.3gW > %.3gW", c.power, c.maxPower)
} else {
c.log.DEBUG.Printf("power: %gW", c.power)
c.log.DEBUG.Printf("power: %.3gW", c.power)
}

if c.maxCurrent != 0 && c.current > c.maxCurrent {
c.log.WARN.Printf("over current detected: %gA > %gA", c.current, c.maxCurrent)
c.log.WARN.Printf("over current detected: %.3gA > %.3gA", c.current, c.maxCurrent)
} else {
c.log.DEBUG.Printf("current: %gA", c.current)
c.log.DEBUG.Printf("current: %.3gA", c.current)
}
}()

Expand Down Expand Up @@ -266,9 +266,9 @@ func (c *Circuit) ValidatePower(old, new float64) float64 {
potential := c.maxPower - c.power
if delta > potential {
new = max(0, old+potential)
c.log.DEBUG.Printf("validate power: %gW -> %gW <= %gW at %gW: capped at %gW", old, new, c.maxPower, c.power, new)
c.log.DEBUG.Printf("validate power: %.3gW -> %.3gW <= %.3gW at %.3gW: capped at %.3gW", old, new, c.maxPower, c.power, new)
} else {
c.log.TRACE.Printf("validate power: %gW -> %gW <= %gW at %gW: ok", old, new, c.maxPower, c.power)
c.log.TRACE.Printf("validate power: %.3gW -> %.3gW <= %.3gW at %.3gW: ok", old, new, c.maxPower, c.power)
}
}

Expand All @@ -287,9 +287,9 @@ func (c *Circuit) ValidateCurrent(old, new float64) float64 {
potential := c.maxCurrent - c.current
if delta > potential {
new = max(0, old+potential)
c.log.DEBUG.Printf("validate current: %gA -> %gA <= %gA at %gA: capped at %gA", old, new, c.maxCurrent, c.current, new)
c.log.DEBUG.Printf("validate current: %.3gA -> %.3gA <= %.3gA at %.3gA: capped at %.3gA", old, new, c.maxCurrent, c.current, new)
} else {
c.log.TRACE.Printf("validate current: %gA -> %gA <= %gA at %gA: ok", old, new, c.maxCurrent, c.current)
c.log.TRACE.Printf("validate current: %.3gA -> %.3gA <= %.3gA at %.3gA: ok", old, new, c.maxCurrent, c.current)
}
}

Expand Down

0 comments on commit 477141e

Please sign in to comment.