diff --git a/main.go b/main.go index 243822af..c8b5b0a5 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "log" "os" "path/filepath" + "runtime/debug" "github.com/leaanthony/mewn" "github.com/marcsauter/single" @@ -19,19 +20,20 @@ import ( func main() { defer func() { if err := recover(); err != nil { - tracking.Track(tracking.TrackingRequest{ - Category: "Lifecycle", - Action: "Crash", - Name: fmt.Sprintf("%v", err), - }) - // Reopen log file, since it's closed now! logging.SetLogLevel(int(logging.LogLevelDebug)) logFilePath := filepath.Join(util.DataDirectory(), "debug.log") logFile, _ := os.OpenFile(logFilePath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) logging.SetLogFile(logFile) defer logFile.Close() - log.Println(err) + logging.Errorf("%v\n%s\n", err, string(debug.Stack())) + + tracking.Track(tracking.TrackingRequest{ + Category: "Lifecycle", + Action: "Crash", + Name: fmt.Sprintf("%v", err), + }) + } }()