fix(cmd/temperatures,humidity): enable logs if flag is true and optimization of variable names

This commit is contained in:
Markus Pesch 2019-06-27 20:31:52 +02:00
parent 6469c0dd6c
commit 6d3781d950
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 10 additions and 9 deletions

View File

@ -5,6 +5,7 @@ import (
"log" "log"
"os" "os"
"github.com/go-flucky/flucky/pkg/logfile"
"github.com/go-flucky/flucky/pkg/types/typeswitch" "github.com/go-flucky/flucky/pkg/types/typeswitch"
"github.com/go-flucky/flucky/pkg/cli" "github.com/go-flucky/flucky/pkg/cli"
@ -46,13 +47,13 @@ var readHumidityCmd = &cobra.Command{
// print humidities on stdout // print humidities on stdout
cli.PrintMeasuredValues(measuredValues, cnf, os.Stdout) cli.PrintMeasuredValues(measuredValues, cnf, os.Stdout)
// if logs { if logs {
// humiditiyLogfile := logfile.New(cnf.Device.HumidityLogfile) logfile := logfile.New(cnf.Device.Logfile)
// err := logfile.AppendTemperatures(humiditiyLogfile, compression, humidities) err := logfile.Append(compression, measuredValues)
// if err != nil { if err != nil {
// log.Fatalln(err) log.Fatalln(err)
// } }
// } }
}, },
} }

View File

@ -50,10 +50,10 @@ var readTemperatureCmd = &cobra.Command{
log.Fatalln(err) log.Fatalln(err)
} }
temperatures := typeswitch.TemperatureValues(measuredValues) measuredValues = typeswitch.TemperatureValues(measuredValues)
// print temperatures on stdout // print temperatures on stdout
cli.PrintMeasuredValues(temperatures, cnf, os.Stdout) cli.PrintMeasuredValues(measuredValues, cnf, os.Stdout)
if logs { if logs {
logfile := logfile.New(cnf.Device.Logfile) logfile := logfile.New(cnf.Device.Logfile)