5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-09 23:20:28 +00:00

Show yggdrasilctl log buffer on panic

This commit is contained in:
Neil Alexander 2018-12-10 11:29:42 +00:00
parent b4b3609678
commit c78e1b98cc
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -26,6 +26,13 @@ type admin_info map[string]interface{}
func main() {
logbuffer := &bytes.Buffer{}
logger := log.New(logbuffer, "", log.Flags())
defer func() {
if r := recover(); r != nil {
logger.Println("Fatal error:", r)
fmt.Print(logbuffer)
os.Exit(1)
}
}()
endpoint := defaults.GetDefaults().DefaultAdminListen
@ -102,7 +109,6 @@ func main() {
conn, err = net.Dial("tcp", endpoint)
}
if err != nil {
fmt.Print(logbuffer)
panic(err)
}
logger.Println("Connected")
@ -137,7 +143,6 @@ func main() {
}
if err := encoder.Encode(&send); err != nil {
fmt.Print(logbuffer)
panic(err)
}
logger.Printf("Request sent")