Skip to content

Commit

Permalink
reduce unnecessary logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dmowcomber committed Aug 8, 2024
1 parent b5e4089 commit c645d31
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
3 changes: 1 addition & 2 deletions rail/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package rail
import (
"errors"
"io"
"log"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -121,7 +120,7 @@ func (t *Track) write(data []byte) error {
defer func() {
serialWriteLatency.Observe(time.Since(start).Seconds())
}()
log.Printf("writing data: %s\n", data)
// log.Printf("writing data: %s\n", data)
_, err := t.serial.Write(data)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion throttle/throttle.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (t *Throttle) write(data []byte) error {
if t.serial == nil {
return errors.New("serial writer has not been initialized")
}
log.Printf("writing data: %s\n", data)
// log.Printf("writing data: %s\n", data)
_, err := t.serial.Write(data)
if err != nil {
return err
Expand Down
2 changes: 0 additions & 2 deletions ui/api/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ func (a *API) stateHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, `{"error":"%s"}`, err.Error())
return
}
fmt.Println(resp)
w.WriteHeader(http.StatusOK)
fmt.Printf("writing data: %s\n", string(data))
w.Write(data)
}

Expand Down
35 changes: 19 additions & 16 deletions ui/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,46 @@ func (c *CLI) Run() error {

switch char {
case 'p':
c.track.PowerToggle()
_, err = c.track.PowerToggle()
case 's':
c.throt.Stop()
err = c.throt.Stop()
case '0':
c.throt.ToggleFunction(0)
_, err = c.throt.ToggleFunction(0)
case '1':
c.throt.ToggleFunction(1)
_, err = c.throt.ToggleFunction(1)
case '2', 'h':
c.throt.ToggleFunction(2)
_, err = c.throt.ToggleFunction(2)
case '3':
c.throt.ToggleFunction(3)
_, err = c.throt.ToggleFunction(3)
case '4':
c.throt.ToggleFunction(4)
_, err = c.throt.ToggleFunction(4)
case '5':
c.throt.ToggleFunction(5)
_, err = c.throt.ToggleFunction(5)
case '6':
c.throt.ToggleFunction(6)
_, err = c.throt.ToggleFunction(6)
case '7':
c.throt.ToggleFunction(7)
_, err = c.throt.ToggleFunction(7)
case '8', 'm':
c.throt.ToggleFunction(8)
_, err = c.throt.ToggleFunction(8)
case '9':
c.throt.ToggleFunction(9)
_, err = c.throt.ToggleFunction(9)
default:
if key == keyboard.KeyArrowUp {
c.throt.ThrottleUp()
err = c.throt.ThrottleUp()
} else if key == keyboard.KeyArrowDown {
c.throt.ThrottleDown()
err = c.throt.ThrottleDown()
} else if key == keyboard.KeyArrowRight {
c.throt.DirectionForward()
err = c.throt.DirectionForward()
} else if key == keyboard.KeyArrowLeft {
c.throt.DirectionBackward()
err = c.throt.DirectionBackward()
} else if key == keyboard.KeyCtrlC {
return nil
} else {
// TODO: print usage
}
}
if err != nil {
log.Print(err.Error())
}
}
}

0 comments on commit c645d31

Please sign in to comment.