From 7b4d1aa0c8803304eb8c6ebf0eee8c0ef465b5a4 Mon Sep 17 00:00:00 2001 From: guohao Date: Thu, 5 Sep 2019 18:29:01 +0800 Subject: [PATCH] add caller info & stdout --- gokit.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gokit.go b/gokit.go index 3062256..8e7ab49 100644 --- a/gokit.go +++ b/gokit.go @@ -106,13 +106,13 @@ func format(level Level, msg string) string { ) pc, file, line, _ = runtime.Caller(3) if withCaller == FullPATH { - context = fmt.Sprintf("%s:%d(%s)", file, line, path.Base(runtime.FuncForPC(pc).Name())) + context = fmt.Sprintf("%-15s:%03d:%s", file, line, path.Base(runtime.FuncForPC(pc).Name())) }else{ - context = fmt.Sprintf("%s:%d(%s)", path.Base(file), line, path.Base(runtime.FuncForPC(pc).Name())) + context = fmt.Sprintf("%-15s:%03d:%s", path.Base(file), line, path.Base(runtime.FuncForPC(pc).Name())) } - return fmt.Sprintf("%s [%s] %s %s \n", time.Now().Format("2006-01-02 15:04:05.999"), getLevelName(level), context, msg) + return fmt.Sprintf("%s\t[%5s]\t%s %s \n", time.Now().Format("2006-01-02 15:04:05.999"), getLevelName(level), context, msg) } else { - return fmt.Sprintf("%s [%s] %s \n", time.Now().Format("2006-01-02 15:04:05.999"), getLevelName(level), msg) + return fmt.Sprintf("%s\t[%5s]\t%s \n", time.Now().Format("2006-01-02 15:04:05.999"), getLevelName(level), msg) } }