Skip to content

Commit

Permalink
print stack on async on panic (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
kelindar committed May 27, 2018
1 parent 84160fa commit c4d13b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions async/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package async
import (
"context"
"fmt"
"runtime/debug"
"time"

"github.com/emitter-io/emitter/provider/logging"
)


// Repeat performs an action asynchronously on a predetermined interval.
func Repeat(ctx context.Context, interval time.Duration, action func()) context.CancelFunc {

Expand Down Expand Up @@ -55,6 +55,6 @@ func Repeat(ctx context.Context, interval time.Duration, action func()) context.
// handlePanic handles the panic and logs it out.
func handlePanic() {
if r := recover(); r != nil {
logging.LogAction("async", fmt.Sprintf("panic recovered: %s", r))
logging.LogAction("async", fmt.Sprintf("panic recovered: %ss \n %s", r, debug.Stack()))
}
}

0 comments on commit c4d13b3

Please sign in to comment.