(traceskip int, err error, t LogType, s string)
| 380 | } |
| 381 | |
| 382 | func (l *Logger) output(traceskip int, err error, t LogType, s string) error { |
| 383 | var stack trace.Stack |
| 384 | if l.isTraceEnabled(t) { |
| 385 | stack = trace.TraceN(traceskip+1, 32) |
| 386 | } |
| 387 | |
| 388 | var b bytes.Buffer |
| 389 | fmt.Fprint(&b, t, " ", s) |
| 390 | |
| 391 | if len(s) == 0 || s[len(s)-1] != '\n' { |
| 392 | fmt.Fprint(&b, "\n") |
| 393 | } |
| 394 | |
| 395 | if err != nil { |
| 396 | fmt.Fprint(&b, "[error]: ", err.Error(), "\n") |
| 397 | if stack := errors.Stack(err); stack != nil { |
| 398 | fmt.Fprint(&b, stack.StringWithIndent(1)) |
| 399 | } |
| 400 | } |
| 401 | if len(stack) != 0 { |
| 402 | fmt.Fprint(&b, "[stack]: \n", stack.StringWithIndent(1)) |
| 403 | } |
| 404 | |
| 405 | s = b.String() |
| 406 | l.mu.Lock() |
| 407 | defer l.mu.Unlock() |
| 408 | return l.log.Output(traceskip+2, s) |
| 409 | } |
| 410 | |
| 411 | func Flags() int { |
| 412 | return StdLog.Flags() |
no test coverage detected