MCPcopy
hub / github.com/CodisLabs/codis / output

Method output

pkg/utils/log/log.go:382–409  ·  view source on GitHub ↗
(traceskip int, err error, t LogType, s string)

Source from the content-addressed store, hash-verified

380}
381
382func (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
411func Flags() int {
412 return StdLog.Flags()

Callers 15

PanicMethod · 0.95
PanicfMethod · 0.95
PanicErrorMethod · 0.95
PanicErrorfMethod · 0.95
ErrorMethod · 0.95
ErrorfMethod · 0.95
ErrorErrorMethod · 0.95
ErrorErrorfMethod · 0.95
WarnMethod · 0.95
WarnfMethod · 0.95
WarnErrorMethod · 0.95
WarnErrorfMethod · 0.95

Calls 4

isTraceEnabledMethod · 0.95
StringWithIndentMethod · 0.95
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected