package log import ( "fmt" "runtime" "text/template" ) func caller(depth int) string { _, file, line, _ := runtime.Caller(depth) short := file for i := len(file) - 1; i > 0; i-- { if file[i] == '/' { short = file[i+1:] break } } return fmt.Sprintf("%s:%d", short, line) } func stack() string { buf := make([]byte, 1024) for { n := runtime.Stack(buf, false) if n < len(buf) { return string(buf[:n]) } buf = make([]byte, 2*len(buf)) } } func getAllOffsprings(l *Logger) []*Logger { if l.subs == nil || len(l.subs) == 0 { return []*Logger{l} } loggers := []*Logger{} for i := range l.subs { loggers = append(loggers, getAllOffsprings(l.subs[i])...) } return loggers } func copyFuncMap(source template.FuncMap) template.FuncMap { dest := template.FuncMap{} for k, v := range source { dest[k] = v } return dest }