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