fix(logfile): Add pkg to operate with logfiles
This commit is contained in:
@ -30,9 +30,11 @@ var rootCmd = &cobra.Command{
|
||||
|
||||
cnf := config.Configuration{
|
||||
Device: &types.Device{
|
||||
DeviceID: uuid.NewV4().String(),
|
||||
DeviceName: hostname,
|
||||
CreationDate: time.Now(),
|
||||
DeviceID: uuid.NewV4().String(),
|
||||
DeviceName: hostname,
|
||||
HumidityLogfile: "/var/log/flucky/humidity.json",
|
||||
TemperatureLogfile: "/var/log/flucky/temperature.json",
|
||||
CreationDate: time.Now(),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/volker-raschek/flucky/pkg/cli"
|
||||
"github.com/volker-raschek/flucky/pkg/config"
|
||||
"github.com/volker-raschek/flucky/pkg/logfile"
|
||||
"github.com/volker-raschek/flucky/pkg/sensor"
|
||||
)
|
||||
|
||||
@ -36,6 +37,13 @@ var readTemperatureCmd = &cobra.Command{
|
||||
|
||||
// print temperatures on stdout
|
||||
cli.PrintTemperatures(temperatures, cnf, os.Stdout)
|
||||
|
||||
if logs {
|
||||
err := logfile.WriteTemperatures(cnf.Device.TemperatureLogfile, temperatures)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user