// logPanic safely executes the given func, recovering from and logging a panic if one occurs.
190355
func logPanic(f func()) {
	defer func() {
		if r := recover(); r != nil {
			log.Errorf("recovered from client panic: %v", r)
		}
	}()
	f()
}
1108719
func (logs *Logs) Panic(v ...interface{}) {
	s := fmt.Sprint(v...)
	logs.all(s)
	logs.Flush()
	panic(s)
}
1150412
func LogPanicWithStack(log Interface, location string, r interface{}, vals ...interface{}) error {
	if log == nil {
		log = internal
	}
	var err error
	switch t := r.(type) {
	case string:
		err = errors.New(t)
	case error:
		err = t
	default:
		err = errors.Errorf("unkown type(%T) error: %v", r, r)
	}
	os.Mkdir("panics", os.ModePerm)
	b, tmpErr := ioutil.TempFile("panics", location)
	if tmpErr != nil {
		log.Log("event", "panic", "location", location, "err", err, "warning", "no temp file", "tmperr", tmpErr)
		return errors.Wrapf(tmpErr, "LogPanic: failed to create httpRecovery log")
	}

	fmt.Fprintf(b, "warning! %s!\nError:\n%+v\n", location, err)
	for i, v := range vals {
		spew.Fdump(b, "val(%d): %#v\n", i, v)
	}
	fmt.Fprintf(b, "\n\nCall Stack:\n%s", debug.Stack())

	log.Log("event", "panic", "location", location, "panicLog", b.Name())
	fmt.Fprintf(os.Stderr, "panicWithStack: wrote %s\n", b.Name())

	return errors.Wrap(b.Close(), "LogPanic: failed to close dump file")
}
526496
func LogHandler(next http.Handler) http.Handler {
	fn := func(w http.ResponseWriter, r *http.Request) {
		tIni := time.Now()
		rw := &responseWriter{w: w}
		next.ServeHTTP(rw, r)
		tEnd := time.Now()
		log.Printf("%v [%s] %q %v %v %v\n", r.RemoteAddr, r.Method, r.URL.String(), rw.Size(), rw.Status(), tEnd.Sub(tIni))
	}

	return http.HandlerFunc(fn)
}
1318511
func dbc_panic(dbc_func_name string, b bool, message ...interface{}) {
	if !b {

		// Get caller information which is the caller
		// of the caller of this function
		pc, file, line, _ := runtime.Caller(2)
		caller_func_info := runtime.FuncForPC(pc)

		error_string := fmt.Sprintf("%s:\n\r\tfunc (%s) 0x%x\n\r\tFile %s:%d",
			dbc_func_name,
			caller_func_info.Name(),
			pc,
			file,
			line)

		if len(message) > 0 {
			error_string += fmt.Sprintf("\n\r\tInfo: %+v", message)
		}
		err := errors.New(error_string)

		// Finally panic
		panic(err)
	}
}
220387
func (n *Notifier) NotifyOnPanic() {
	if v := recover(); v != nil {
		notice := n.Notice(v, nil, 2)
		notice.Context["severity"] = "critical"
		n.SendNotice(notice)
		panic(v)
	}
}
149861
func getPanicLogger() *zap.Logger {
	panicLoggerOnce.Do(func() {
		panicLogger = influxlogger.New(os.Stderr)
		panicLogger = panicLogger.With(zap.String("handler", "panic"))
	})

	return panicLogger
}
109947
func recoverPanic(j *Job) {
	if r := recover(); r != nil {
		// record an error on the job with panic message and stacktrace
		stackBuf := make([]byte, 1024)
		n := runtime.Stack(stackBuf, false)

		buf := &bytes.Buffer{}
		fmt.Fprintf(buf, "%v\n", r)
		fmt.Fprintln(buf, string(stackBuf[:n]))
		fmt.Fprintln(buf, "[...]")
		stacktrace := buf.String()
		log.Printf("event=panic job_id=%d job_type=%s\n%s", j.ID, j.Type, stacktrace)
		if err := j.Error(stacktrace); err != nil {
			log.Printf("attempting to save error on job %d: %v", j.ID, err)
		}
	}
}
709505
func (sm *ServeMux) HandlePanic(err error, e1 interface{}) error {
	if e1 == nil { // no panic, return the given error.
		return err
	}
	if err != nil { // an error is already present. log the panic and return the given error.
		sm.log.Printf("Handler panic recovered: %v", e1)
		return err
	}
	// we have a panic and no given error.
	e2, ok := e1.(error)
	if !ok { // the panic is not an error, create an error out of the string representation of the panic.
		return fmt.Errorf("(%T) %v", e1, e1)
	}
	// return the panic error
	return e2
}
657506
func (g *Grip) sendPanic(m message.Composer) {
	// the Send method in the Sender interface will perform this
	// check but to add fatal methods we need to do this here.
	g.mu.RLock()
	defer g.mu.RUnlock()

	if g.impl.Level().ShouldLog(m) {
		g.impl.Send(m)
		panic(m.String())
	}
}
849973
func (n *LevelLogger) Panic(v ...interface{}) {
	if !n.Enabled() {
		return
	}
	s := fmt.Sprint(v...)
	n.mu.RLock()
	n.logger.Output(callDepth, s)
	n.mu.RUnlock()
	panic(s)
}
806380
func (c *context) Panic(format string, args ...interface{}) {
	c.logger.Panic(c.prefixFormat()+format, args...)
}
255543
func PanicFunc(err error, f fn, message string, args ...interface{}) {
	if err != nil {
		f()
		logger.Printf(message+"\n", args...)
		panic(err)
	}
}
571524
func (plugin *ExamplePlugin) showPanicLog() {
	defer func() {
		if err := recover(); err != nil {
			plugin.Log.Info("Recovered from panic")
		}
	}()
	plugin.Log.Panic("Panic log: calls panic() after log, will be recovered") //calls panic() after logging
}
437804
func (p *PackageLogger) Panicf(format string, args ...interface{}) {
	s := fmt.Sprintf(format, args...)
	p.internalLog(calldepth, CRITICAL, s)
	panic(s)
}
1306290
func parseOrPanic(simplify bool, pattern string) *syntax.Regexp {
	regexp, err := syntax.Parse(pattern, 0)
	if err != nil {
		panic(err)
	}
	if simplify {
		regexp = regexp.Simplify()
	}
	return regexp
}
1048159
func (l *DefaultLogger) LogPanic(_ context.Context, value interface{}) {
	const size = 64 << 10
	buf := make([]byte, size)
	buf = buf[:runtime.Stack(buf, false)]
	log.Printf("graphql: panic occurred: %v\n%s", value, buf)
}