mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-23 18:15:24 +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() {
|
func main() {
|
||||||
logbuffer := &bytes.Buffer{}
|
logbuffer := &bytes.Buffer{}
|
||||||
logger := log.New(logbuffer, "", log.Flags())
|
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
|
endpoint := defaults.GetDefaults().DefaultAdminListen
|
||||||
|
|
||||||
@ -102,7 +109,6 @@ func main() {
|
|||||||
conn, err = net.Dial("tcp", endpoint)
|
conn, err = net.Dial("tcp", endpoint)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Print(logbuffer)
|
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
logger.Println("Connected")
|
logger.Println("Connected")
|
||||||
@ -137,7 +143,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := encoder.Encode(&send); err != nil {
|
if err := encoder.Encode(&send); err != nil {
|
||||||
fmt.Print(logbuffer)
|
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
logger.Printf("Request sent")
|
logger.Printf("Request sent")
|
||||||
|
Loading…
Reference in New Issue
Block a user