go-cqhttp
go-cqhttp copied to clipboard
replace logrus with internal/log
reduce binary size about 100k
shortcoming:
- unfriendly to ide highlighting
- unflexible
我自己也替换了下,没想到这里有PR了。建议吧logrus的行号和代码文件整出来。 我的效果如下:

优化了下,直接点击就可以跳转到打日志的位置,方便调试。

实现
import nested "github.com/antonfisher/nested-logrus-formatter"
import "github.com/sirupsen/logrus"
func init() {
logrus.SetLevel(logrus.InfoLevel)
logrus.SetReportCaller(true)
logrus.SetFormatter(&nested.Formatter{
HideKeys: true,
FieldsOrder: []string{"component", "category", "req"},
CustomCallerFormatter: func(f *runtime.Frame) string {
return fmt.Sprintf(" ( %s:%d )", f.File, f.Line)
},
})
}