From 986a05c215723b9227db20aa11a62e4d924281cb Mon Sep 17 00:00:00 2001 From: Daniel Langesten Date: Thu, 26 Mar 2015 11:09:48 +0100 Subject: added verbose option to enable/disable extra output from the program --- flow-cleaner.go | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'flow-cleaner.go') diff --git a/flow-cleaner.go b/flow-cleaner.go index 9e038cf..eaa5559 100644 --- a/flow-cleaner.go +++ b/flow-cleaner.go @@ -10,6 +10,7 @@ import ( var ( flogger *log.Logger + VERBOSE bool ) func init() { @@ -17,7 +18,9 @@ func init() { } func main() { + flogger.Println("Now running Flow-cleaner") cfg, err := readConfig() + VERBOSE = cfg.Verbose if err != nil { flogger.Println("Could not read config") return @@ -36,18 +39,24 @@ func main() { } func processFromStdin(cfg *Config) { - flogger.Println("Starting to process from stdin...") + if VERBOSE { + flogger.Println("Starting to process from stdin...") + } input := readFromStdin() rDatChan := parseRawData(input, cfg) err := cleanFromStdin(rDatChan, cfg) if err != nil { flogger.Println("Failed to clean data:", err) } - flogger.Println("Finished processing from stdin!") + if VERBOSE { + flogger.Println("Finished processing from stdin!") + } } func processFromDB(cfg *Config) { - flogger.Print("Starting to process from db...") + if VERBOSE { + flogger.Println("Starting to process from db...") + } starttime := time.Now() numOfRowsNotCleaned, err := cleanFromDB(cfg) if err != nil { @@ -55,12 +64,16 @@ func processFromDB(cfg *Config) { flogger.Println("Exiting...") return } - flogger.Println("Finished processing from db!") + if VERBOSE { + flogger.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 if (numOfRowsNotCleaned == 0 || cfg.Limit == 0) && cfg.Epsilon >= 0 { - flogger.Println("Adding differential privacy noise to processed data...") + if VERBOSE { + flogger.Println("Adding differential privacy noise to processed data...") + } db, err := sql.Open("mysql", cfg.DBUser+":"+cfg.DBPass+"@"+cfg.DBConn+"/"+cfg.DBName) if err != nil { flogger.Println("Failed to connect to db:", err) @@ -78,6 +91,8 @@ func processFromDB(cfg *Config) { if err != nil { flogger.Println("Failed to privatize data:", err) } - flogger.Println("Done!") + if VERBOSE { + flogger.Println("Done!") + } } } -- cgit v1.1