use log instead of fmt.
This commit is contained in:
parent
aa04754f66
commit
777f857593
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"sync"
|
||||
@ -47,7 +46,7 @@ func httpServer(wg *sync.WaitGroup, host string, port int) *http.Server {
|
||||
defer wg.Done()
|
||||
|
||||
if err := srvr.ListenAndServe(); err != http.ErrServerClosed {
|
||||
fmt.Printf("[ERROR] Webserver Error: %v\n", err)
|
||||
log.Printf("[ERROR] Webserver Error: %v\n", err)
|
||||
wg.Done()
|
||||
}
|
||||
}()
|
||||
|
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"net/http"
|
||||
@ -56,7 +55,7 @@ func readTemp(wg *sync.WaitGroup, shutdown <-chan bool, temper []*temper.Temper,
|
||||
// read celsius from TERMer
|
||||
f, err := temper[0].ReadC()
|
||||
if err != nil {
|
||||
fmt.Printf("[ERROR] Unable to read from TEMPer: %v\n", err)
|
||||
log.Printf("[ERROR] Unable to read from TEMPer: %v\n", err)
|
||||
}
|
||||
|
||||
// trim result
|
||||
@ -67,12 +66,12 @@ func readTemp(wg *sync.WaitGroup, shutdown <-chan bool, temper []*temper.Temper,
|
||||
config.Prometheus.Temperature.With(prometheus.Labels{"unit": "celsius"}).Set(celsius)
|
||||
config.Prometheus.Temperature.With(prometheus.Labels{"unit": "fahrenheit"}).Set(fahrenheit)
|
||||
config.Prometheus.Temperature.With(prometheus.Labels{"unit": "kelvin"}).Set(kelvin)
|
||||
fmt.Printf("[DEBUG] Read from TEMPer: %fF (%fC)\n", fahrenheit, celsius)
|
||||
log.Printf("[DEBUG] Read from TEMPer: %fF (%fC)\n", fahrenheit, celsius)
|
||||
|
||||
// reset the timer
|
||||
t.Reset(timeout)
|
||||
case <-shutdown:
|
||||
fmt.Println("[INFO] Stopped Collecting Temperature")
|
||||
log.Println("[INFO] Stopped Collecting Temperature\n")
|
||||
|
||||
// clear the task form the wait-group
|
||||
wg.Done()
|
||||
@ -100,10 +99,10 @@ func main() {
|
||||
tempers, err := temper.FindTempers()
|
||||
switch {
|
||||
case err != nil:
|
||||
fmt.Printf("[ERROR] Unable to identify TEMPer device: %v\n", err)
|
||||
log.Printf("[ERROR] Unable to identify TEMPer device: %v\n", err)
|
||||
return
|
||||
case len(tempers) == 0:
|
||||
fmt.Println("[ERROR] No TEMPer found")
|
||||
log.Println("[ERROR] No TEMPer found")
|
||||
return
|
||||
}
|
||||
reader := make(chan bool, 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user