diff options
| author | Daniel Langesten <daniel.langest@gmail.com> | 2015-03-26 11:09:48 +0100 |
|---|---|---|
| committer | Daniel Langesten <daniel.langest@gmail.com> | 2015-03-26 11:09:48 +0100 |
| commit | 986a05c215723b9227db20aa11a62e4d924281cb (patch) | |
| tree | 6401602986bb32827b9defe43faa5e5e93c527f1 /flow-cleaner.go | |
| parent | 54f6128240711a93551d85b000766a9b57cc96cf (diff) | |
added verbose option to enable/disable extra output from the program
Diffstat (limited to 'flow-cleaner.go')
| -rw-r--r-- | flow-cleaner.go | 27 |
1 files changed, 21 insertions, 6 deletions
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!") + } } } |
