diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 43e41c6d7..56aad526e 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -23,6 +23,7 @@ import ( "math" "os" "os/signal" + "path/filepath" "runtime" "strconv" "strings" @@ -38,17 +39,18 @@ import ( // https://www.faa.gov/nextgen/programs/adsb/Archival/ // https://www.faa.gov/nextgen/programs/adsb/Archival/media/GDL90_Public_ICD_RevA.PDF -var debugLogf string // Set according to OS config. +var logDirf string // Directory for all logging +var debugLogf string // Set according to OS config. var dataLogFilef string // Set according to OS config. const ( configLocation = "/etc/stratux.conf" managementAddr = ":80" - debugLog = "/var/log/stratux.log" - dataLogFile = "/var/log/stratux.sqlite" + logDir = "/var/log/" + debugLogFile = "stratux.log" + dataLogFile = "stratux.sqlite" //FlightBox: log to /root. - debugLog_FB = "/root/stratux.log" - dataLogFile_FB = "/var/log/stratux.sqlite" + logDir_FB = "/root/" maxDatagramSize = 8192 maxUserMsgQueueSize = 25000 // About 10MB per port per connected client. @@ -1345,12 +1347,12 @@ func main() { //FlightBox: detect via presence of /etc/FlightBox file. if _, err := os.Stat("/etc/FlightBox"); !os.IsNotExist(err) { globalStatus.HardwareBuild = "FlightBox" - debugLogf = debugLog_FB - dataLogFilef = dataLogFile_FB + logDirf = logDir_FB } else { // if not using the FlightBox config, use "normal" log file locations - debugLogf = debugLog - dataLogFilef = dataLogFile + logDirf = logDir } + debugLogf = filepath.Join(logDirf, debugLogFile) + dataLogFilef = filepath.Join(logDirf, dataLogFile) //FIXME: All of this should be removed by 08/01/2016. // Check if Raspbian version is <8.0. Throw a warning if so. vt, err := ioutil.ReadFile("/etc/debian_version") @@ -1387,7 +1389,7 @@ func main() { timeStarted = time.Now() runtime.GOMAXPROCS(runtime.NumCPU()) // redundant with Go v1.5+ compiler - // Duplicate log.* output to debugLog. + // Duplicate log.* output to debugLogFile. fp, err := os.OpenFile(debugLogf, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { err_log := fmt.Errorf("Failed to open '%s': %s", debugLogf, err.Error()) diff --git a/main/sensors.go b/main/sensors.go index 6280dcb48..85d2e8189 100644 --- a/main/sensors.go +++ b/main/sensors.go @@ -13,6 +13,7 @@ import ( // "github.com/kidoman/embd/sensor/bmp180" "github.com/westphae/goflying/ahrs" "github.com/westphae/goflying/ahrsweb" + "path/filepath" ) const numRetries uint8 = 5 @@ -274,7 +275,8 @@ func sensorAttitudeSender() { // Log it to csv for analysis if globalSettings.AHRSLog { if analysisLogger == nil { - analysisFilename := fmt.Sprintf("/var/log/sensors_%s.csv", time.Now().Format("20060102_150405")) + analysisFilename := filepath.Join(logDirf, fmt.Sprintf("sensors_%s.csv", + time.Now().Format("20060102_150405"))) analysisLogger = ahrs.NewAHRSLogger(analysisFilename, s.GetLogMap()) }