From 6d3781d95053fd73110f91e48db2f86f5c8bbe54 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Thu, 27 Jun 2019 20:31:52 +0200 Subject: [PATCH] fix(cmd/temperatures,humidity): enable logs if flag is true and optimization of variable names --- cmd/humidity/read.go | 15 ++++++++------- cmd/temperature/read.go | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cmd/humidity/read.go b/cmd/humidity/read.go index de2ca56..88e4f04 100644 --- a/cmd/humidity/read.go +++ b/cmd/humidity/read.go @@ -5,6 +5,7 @@ import ( "log" "os" + "github.com/go-flucky/flucky/pkg/logfile" "github.com/go-flucky/flucky/pkg/types/typeswitch" "github.com/go-flucky/flucky/pkg/cli" @@ -46,13 +47,13 @@ var readHumidityCmd = &cobra.Command{ // print humidities on stdout cli.PrintMeasuredValues(measuredValues, cnf, os.Stdout) - // if logs { - // humiditiyLogfile := logfile.New(cnf.Device.HumidityLogfile) - // err := logfile.AppendTemperatures(humiditiyLogfile, compression, humidities) - // if err != nil { - // log.Fatalln(err) - // } - // } + if logs { + logfile := logfile.New(cnf.Device.Logfile) + err := logfile.Append(compression, measuredValues) + if err != nil { + log.Fatalln(err) + } + } }, } diff --git a/cmd/temperature/read.go b/cmd/temperature/read.go index 98a3d81..d645a8f 100644 --- a/cmd/temperature/read.go +++ b/cmd/temperature/read.go @@ -50,10 +50,10 @@ var readTemperatureCmd = &cobra.Command{ log.Fatalln(err) } - temperatures := typeswitch.TemperatureValues(measuredValues) + measuredValues = typeswitch.TemperatureValues(measuredValues) // print temperatures on stdout - cli.PrintMeasuredValues(temperatures, cnf, os.Stdout) + cli.PrintMeasuredValues(measuredValues, cnf, os.Stdout) if logs { logfile := logfile.New(cnf.Device.Logfile)