The below is an example of a function which basically enables or disables writes to a file.
func getdebugmode(d bool, env string) {
log.SetOutput(ioutil.Discard) //discard all writes by default
if d == true {
f, _ := os.OpenFile("/app/monitoring/appdyn/logs/appdyn_server_monitoring_events_" + env + ".log", os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666)
log.SetOutput(f)
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
}
Is it possible instead of discarding all writes to allow log.Fatalf writes to go into the log but not writes using log.Println unless I specify the bool to be true.
I am trying to use log.Println as "INFORMATIONAL" alerts and log.Fatalf as "Error" alerts.