use log
This commit is contained in:
parent
ea3c096ea9
commit
dcd1a03c69
@ -3,6 +3,7 @@ package config
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"th7/data/config"
|
"th7/data/config"
|
||||||
"th7/data/thermocouple"
|
"th7/data/thermocouple"
|
||||||
@ -80,7 +81,7 @@ func Load() (config.Config, error) {
|
|||||||
|
|
||||||
tc, err := GetThermocoupleType(v.GetString(head + ".type"))
|
tc, err := GetThermocoupleType(v.GetString(head + ".type"))
|
||||||
if err != nil {
|
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
|
return cfg, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -84,7 +85,7 @@ func NewInfluxDBAdapter(config config.Config) (*InfluxDBAdapter, error) {
|
|||||||
`
|
`
|
||||||
_, err = adapter.client.Query(initContext, query)
|
_, err = adapter.client.Query(initContext, query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error initialising InfluxDB. Check details/network connection.")
|
log.Println("Error initialising InfluxDB. Check details/network connection.")
|
||||||
return &adapter, err
|
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
|
// need at least 1 iteration to bother sending data to influx server
|
||||||
if logged == 0 {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +137,7 @@ func (ad *InfluxDBAdapter) Save(channels []core.Channel) error {
|
|||||||
return err
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
5
main.go
5
main.go
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@ -55,7 +54,7 @@ func main() {
|
|||||||
defer dbPort.Close()
|
defer dbPort.Close()
|
||||||
|
|
||||||
color.Set(color.FgHiRed)
|
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()
|
color.Unset()
|
||||||
|
|
||||||
// if noweb is false and HTTP/REST API is enabled then start web service
|
// if noweb is false and HTTP/REST API is enabled then start web service
|
||||||
@ -64,7 +63,7 @@ func main() {
|
|||||||
go apiPort.Run()
|
go apiPort.Run()
|
||||||
|
|
||||||
color.Set(color.FgHiGreen)
|
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()
|
color.Unset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package pcb
|
package pcb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"th7/data/pcb"
|
"th7/data/pcb"
|
||||||
"time"
|
"time"
|
||||||
@ -17,7 +17,7 @@ func NewDummyAdapter() (*DummyAdapter, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DummyAdapter) Deinit() error {
|
func (d *DummyAdapter) Deinit() error {
|
||||||
fmt.Println("dummy pcb adapter deinit")
|
log.Println("dummy pcb adapter deinit")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user