1 Star 0 Fork 0

iotas/toolkit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
init.go 779 Bytes
一键复制 编辑 原始数据 按行查看 历史
xuthus 提交于 4年前 . fix
package proto_parser
import (
"fmt"
nested "github.com/antonfisher/nested-logrus-formatter"
log "github.com/sirupsen/logrus"
"os"
"runtime"
"strings"
)
func init() {
var getServeDir = func(path string) string {
var run, _ = os.Getwd()
return strings.Replace(path, run, ".", -1)
}
var formatter = &nested.Formatter{
NoColors: false,
HideKeys: true,
TimestampFormat: "2006-01-02 15:04:05",
CallerFirst: true,
CustomCallerFormatter: func(f *runtime.Frame) string {
s := strings.Split(f.Function, ".")
funcName := s[len(s)-1]
return fmt.Sprintf(" [%s:%d][%s()]", getServeDir(f.File), f.Line, funcName)
},
}
if runtime.GOOS == "windows" {
formatter.NoColors = true
}
log.SetFormatter(formatter)
log.SetReportCaller(true)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/iotas/toolkit.git
git@gitee.com:iotas/toolkit.git
iotas
toolkit
toolkit
6a2c4ec13c63

搜索帮助