From 244fba51eb4807dc8195edf722c742acbbc18ac3 Mon Sep 17 00:00:00 2001 From: Daniel Langesten Date: Thu, 19 Mar 2015 10:44:47 +0100 Subject: improved logging --- flow-cleaner.go | 5 +++-- stdin.go | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/flow-cleaner.go b/flow-cleaner.go index 71c1196..e840c41 100644 --- a/flow-cleaner.go +++ b/flow-cleaner.go @@ -39,10 +39,11 @@ func processFromStdin(cfg *Config) { input := readFromStdin() rDatChan := parseRawData(input, cfg) cleanFromStdin(rDatChan, cfg) + logger.Println("Finished processing from stdin!") } func processFromDB(cfg *Config) { - logger.Print("Cleaning data...") + logger.Print("Starting to process from db...") starttime := time.Now() numOfRowsNotCleaned, err := cleanFromDB(cfg) if err != nil { @@ -50,7 +51,7 @@ func processFromDB(cfg *Config) { logger.Println("Exiting...") return } - logger.Println("Done!") + logger.Println("Finished processing from db!") // If either all rows are processed or if there is no limit for the processing // we can safely add noise to the cleaned data diff --git a/stdin.go b/stdin.go index d79252e..7fadf06 100644 --- a/stdin.go +++ b/stdin.go @@ -22,10 +22,12 @@ func init() { func readFromStdin() <-chan []byte { out := make(chan []byte) go func() { + logger.Println("Now listening on stdin...") scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { out <- []byte(scanner.Text()) } + logger.Println("Finished listening to stdin!") close(out) }() return out @@ -38,6 +40,7 @@ func parseRawData(in <-chan []byte, cfg *Config) <-chan []RawData { logger.Println("Could not parse interval: ", err) } timeBin := time.Now().Add(ival / -2) //Make sure we are inside the correct timeBin + logger.Println("Now parsing data from stdin...") go func() { rDat := make([]RawData, 0) for line := range in { @@ -73,6 +76,7 @@ func parseRawData(in <-chan []byte, cfg *Config) <-chan []RawData { if len(rDat) > 0 { out <- rDat } + logger.Println("Finished parsing data from stdin...") close(out) }() return out -- cgit v1.1