diff --git a/hdiet.go b/hdiet.go index a53e084..66bda52 100644 --- a/hdiet.go +++ b/hdiet.go @@ -72,7 +72,7 @@ func log(args []string) error { if !isInitialized() { return errNotInitialized() } - if len(args) != 1 { + if len(args) < 1 { return errors.New("log: Please provide weight as argument (floating point number)") } weight, err := strconv.ParseFloat(args[0], 64) @@ -80,10 +80,12 @@ func log(args []string) error { return errors.New("log: " + err.Error()) } date := time.Now().Format(dateLayout) - err = goutil.AppendToFile(logfile, fmt.Sprintf("%s\t%.1f\n", date, weight)) + newline := fmt.Sprintf("%s\t%.1f\t%s\n", date, weight, strings.Join(args[1:], " ")) + err = goutil.AppendToFile(logfile, newline) if err != nil { return err } + fmt.Print(newline) return show(showFlags{}) }