This commit is contained in:
William Clark 2023-12-13 08:17:16 +00:00
parent ea3c096ea9
commit dcd1a03c69
4 changed files with 10 additions and 9 deletions

View File

@ -3,6 +3,7 @@ package config
import (
"errors"
"fmt"
"log"
"strings"
"th7/data/config"
"th7/data/thermocouple"
@ -80,7 +81,7 @@ func Load() (config.Config, error) {
tc, err := GetThermocoupleType(v.GetString(head + ".type"))
if err != nil {
fmt.Printf("%s.type=%s\n", head, v.GetString(head+".type"))
log.Printf("%s.type=%s\n", head, v.GetString(head+".type"))
return cfg, err
}

View File

@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"log"
"os"
"strings"
"sync"
@ -84,7 +85,7 @@ func NewInfluxDBAdapter(config config.Config) (*InfluxDBAdapter, error) {
`
_, err = adapter.client.Query(initContext, query)
if err != nil {
fmt.Println("Error initialising InfluxDB. Check details/network connection.")
log.Println("Error initialising InfluxDB. Check details/network connection.")
return &adapter, err
}
@ -124,7 +125,7 @@ func (ad *InfluxDBAdapter) Save(channels []core.Channel) error {
// need at least 1 iteration to bother sending data to influx server
if logged == 0 {
fmt.Printf("[%s] InfluxDB: nothing to do.\n", time.Now().Format(time.DateTime))
log.Printf("[%s] InfluxDB: nothing to do.\n", time.Now().Format(time.DateTime))
return nil
}
@ -136,7 +137,7 @@ func (ad *InfluxDBAdapter) Save(channels []core.Channel) error {
return err
}
fmt.Printf("[%s] InfluxDB: logged %d channels OK\n", time.Now().Format(time.DateTime), logged)
log.Printf("[%s] InfluxDB: logged %d channels OK\n", time.Now().Format(time.DateTime), logged)
return nil
}

View File

@ -1,7 +1,6 @@
package main
import (
"fmt"
"log"
"os"
"os/signal"
@ -55,7 +54,7 @@ func main() {
defer dbPort.Close()
color.Set(color.FgHiRed)
fmt.Printf("Started on: %s\n", time.Now().Format(time.DateTime))
log.Printf("Started on: %s\n", time.Now().Format(time.DateTime))
color.Unset()
// if noweb is false and HTTP/REST API is enabled then start web service
@ -64,7 +63,7 @@ func main() {
go apiPort.Run()
color.Set(color.FgHiGreen)
fmt.Printf("TH7 API is live on http://localhost:%d/\n", cfg.API.Port)
log.Printf("TH7 API is live on http://localhost:%d/\n", cfg.API.Port)
color.Unset()
}

View File

@ -1,7 +1,7 @@
package pcb
import (
"fmt"
"log"
"math/rand"
"th7/data/pcb"
"time"
@ -17,7 +17,7 @@ func NewDummyAdapter() (*DummyAdapter, error) {
}
func (d *DummyAdapter) Deinit() error {
fmt.Println("dummy pcb adapter deinit")
log.Println("dummy pcb adapter deinit")
return nil
}