func (l *Logger) output(traceskip int, err error, t LogType, s string) error { var stack trace.Stack if l.isTraceEnabled(t) { stack = trace.TraceN(traceskip+1, 32) } var b bytes.Buffer if t != 0 { fmt.Fprint(&b, t, " ", s) } else { fmt.Fprint(&b, "[LOG] ", s) } if len(s) == 0 || s[len(s)-1] != '\n' { fmt.Fprint(&b, "\n") } if len(stack) != 0 { fmt.Fprint(&b, "[stack]: \n", stack.StringWithIndent(1)) } if err != nil { fmt.Fprint(&b, "[error]: ", err.Error(), "\n") if stack := errors.ErrorStack(err); stack != nil { fmt.Fprint(&b, stack.StringWithIndent(1)) } } s = b.String() l.mu.Lock() defer l.mu.Unlock() return l.log.Output(traceskip+2, s) }
func ErrorIsNil(t *testing.T, err error) { if err == nil { return } stack := errors.ErrorStack(err) if stack == nil { stack = trace.TraceN(1, 32) } t.Fatalf("%s\n%s", err, stack) }