fix line width

master v0.1.6
guohao 5 years ago
parent 034f0826d6
commit ee01150d3b
  1. 8
      gokit.go

@ -118,18 +118,18 @@ func format(level Level, msg string) string {
pc, file, line, _ = runtime.Caller(3) pc, file, line, _ = runtime.Caller(3)
switch withCaller { switch withCaller {
case FullPATHFunc: case FullPATHFunc:
context = fmt.Sprintf("%s:%03d::%s", file, line, path.Base(runtime.FuncForPC(pc).Name())) context = fmt.Sprintf("%s:%03d::%30s", file, line, path.Base(runtime.FuncForPC(pc).Name()))
case BasePathFunc: case BasePathFunc:
context = fmt.Sprintf("%s:%03d::%s", path.Base(file), line, path.Base(runtime.FuncForPC(pc).Name())) context = fmt.Sprintf("%s:%03d::%30s", path.Base(file), line, path.Base(runtime.FuncForPC(pc).Name()))
case BasePath: case BasePath:
context = fmt.Sprintf("%s:%03d", path.Base(file), line) context = fmt.Sprintf("%s:%03d", path.Base(file), line)
default: default:
context = fmt.Sprintf("%s:%03d", path.Base(file), line) context = fmt.Sprintf("%s:%03d", path.Base(file), line)
} }
return fmt.Sprintf("%s\t[%3s]\t%s\t%s\n", time.Now().Format("2006-01-02 15:04:05.999"), getLevelName(level), context, msg) return fmt.Sprintf("%s\t[%4s]\t%s\t%s\n", time.Now().Format("2006-01-02 15:04:05.999"), getLevelName(level), context, msg)
} else { } else {
return fmt.Sprintf("%s\t[%3s]\t%s\n", time.Now().Format("2006-01-02 15:04:05.999"), getLevelName(level), msg) return fmt.Sprintf("%s\t[%4s]\t%s\n", time.Now().Format("2006-01-02 15:04:05.999"), getLevelName(level), msg)
} }
} }

Loading…
Cancel
Save