November 2017
Intermediate to advanced
670 pages
17h 35m
English
Here we pass the name of our trace file, called trace-log.txt, which will receive all of the logging output. We don't want Debug information, but we do want Info and Error output:
InitLog("trace-log.txt", ioutil.Discard, os.Stdout, os.Stderr)
This time we pass nil for the name of our trace log file, which tells our logger not to create a trace log file. We do want Debug, Info, and Error data displayed to standard out in our terminal console.
InitLog(nil, os.Stdout, os.Stdout, os.Stderr)
When we specify traceFileName, we'll need to create an io.MultiWriter interface to send the output to two places at the same time:
if len(traceFileName) > 0 { _ = os.Remove(traceFileName) file, err := os.OpenFile(traceFileName, os.O_CREATE ...