# README
日志
用trace_id将同一个线程的日志串起来
从ctx获取trace_id
logrus提供了WithContext方法传递ctx,因此只需实现logrus提供的Format接口,即可在打印日志前设置trace_id
// import "zlutils/xray"
func (f MyFormatter) Format(e *logrus.Entry) (serialized []byte, err error) {
traceId := xray.GetTraceId(e.Context)
if traceId != "" {
e.Data["trace_id"] = traceId
}
...
}
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
NOTE: 上线后日志级别当高于debug,对性能有影响.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author