Skip to content

Commit

Permalink
All logs go to /root/ for FlightBox.
Browse files Browse the repository at this point in the history
  • Loading branch information
westphae committed Mar 5, 2017
1 parent f1ff150 commit 5667c1a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 12 additions & 10 deletions main/gen_gdl90.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"math"
"os"
"os/signal"
"path/filepath"
"runtime"
"strconv"
"strings"
Expand All @@ -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.

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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())
Expand Down
4 changes: 3 additions & 1 deletion main/sensors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
}

Expand Down

0 comments on commit 5667c1a

Please sign in to comment.