1
0
Fork 0

Use debug.PrintStack helper instead of handling stack manually

This commit is contained in:
Gregory Eremin 2015-10-14 03:23:27 +03:00
parent e08841fdc7
commit c740f13063
1 changed files with 4 additions and 8 deletions

View File

@ -2,11 +2,10 @@ package uberdaemon
import (
"fmt"
"runtime"
"log"
"runtime/debug"
"strings"
"time"
"log"
)
// Daemon is the interface that contains a set of methods required to be
@ -106,13 +105,10 @@ func (b *BaseDaemon) base() *BaseDaemon {
func (b *BaseDaemon) handlePanic() {
if err := recover(); err != nil {
b.stats.registerError()
trace := make([]byte, 1024)
runtime.Stack(trace, false)
if b.panicHandler != nil {
b.panicHandler()
}
log.Printf("Daemon %s recovered from panic. Error: %v\n%s\n", b, err, trace)
log.Printf("Daemon %s recovered from panic. Error: %v\n", b, err)
debug.PrintStack()
}
}