Skip to content

Small refactorings #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Output stackstrace in log in case of crash
  • Loading branch information
cmaglie committed Nov 9, 2020
commit a03fc2034e8ab58a44f4e44614b3ef48c7f29f6e
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime/debug"

"github.com/bcmi-labs/arduino-language-server/handler"
"github.com/bcmi-labs/arduino-language-server/streams"
Expand All @@ -33,7 +34,13 @@ func main() {

if enableLogging {
logfile := openLogFile("inols-err.log")
defer logfile.Close()
defer func() {
// In case of panic output the stack trace in the log file before exiting
if r := recover(); r != nil {
log.Println(string(debug.Stack()))
}
logfile.Close()
}()
log.SetOutput(logfile)
} else {
log.SetOutput(os.Stderr)
Expand Down