mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-25 23:01:38 +00:00
Show yggdrasilctl log buffer on panic
This commit is contained in:
parent
b4b3609678
commit
c78e1b98cc
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user