diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 3b969e13..f5c463d1 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -832,12 +832,13 @@ func main() { runtime.GOMAXPROCS(runtime.NumCPU()) // redundant with Go v1.5+ compiler // Duplicate log.* output to debugLog. + var mfp io.Writer fp, err := os.OpenFile(debugLog, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { log.Printf("Failed to open '%s': %s\n", debugLog, err.Error()) } else { defer fp.Close() - mfp := io.MultiWriter(fp, os.Stdout) + mfp = io.MultiWriter(fp, os.Stdout) log.SetOutput(mfp) } @@ -847,7 +848,7 @@ func main() { MsgLog = make([]msg, 0) crcInit() // Initialize CRC16 table. - sdrInit() + sdrInit(mfp) initTraffic() globalStatus.Version = stratuxVersion diff --git a/main/sdr.go b/main/sdr.go index ef3b2a88..e26bdeb7 100644 --- a/main/sdr.go +++ b/main/sdr.go @@ -1,6 +1,7 @@ package main import ( + "io" "log" "os/exec" "strconv" @@ -23,6 +24,7 @@ type ES struct { indexID int } +var mfp io.Writer var UATDev *UAT var ESDev *ES @@ -38,6 +40,10 @@ func (e *ES) read() { defer es_wg.Done() log.Println("Entered ES read() ...") cmd := exec.Command("/usr/bin/dump1090", "--net", "--device-index", strconv.Itoa(e.indexID)) + if mfp != nil { + cmd.Stdout = mfp + cmd.Stderr = cmd.Stdout + } err := cmd.Start() if err != nil { log.Printf("Error executing /usr/bin/dump1090: %s\n", err.Error()) @@ -382,7 +388,8 @@ func sdrWatcher() { } } -func sdrInit() { +func sdrInit(m io.Writer) { + mfp = m go sdrWatcher() go uatReader() godump978.Dump978Init()