feat: add gls
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"gitea.com/bitwsd/document_ai/pkg/requestid"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
)
|
||||
@@ -67,8 +69,13 @@ func log(ctx context.Context, level zerolog.Level, logType LogType, kv ...interf
|
||||
// 添加日志类型
|
||||
event.Str("type", string(logType))
|
||||
|
||||
// 添加请求ID
|
||||
if reqID, exists := ctx.Value("request_id").(string); exists {
|
||||
reqID := requestid.GetRequestID()
|
||||
if reqID == "" {
|
||||
if id, exists := ctx.Value("request_id").(string); exists {
|
||||
reqID = id
|
||||
}
|
||||
}
|
||||
if reqID != "" {
|
||||
event.Str("request_id", reqID)
|
||||
}
|
||||
|
||||
@@ -149,4 +156,3 @@ func Fatal(ctx context.Context, kv ...interface{}) {
|
||||
func Access(ctx context.Context, kv ...interface{}) {
|
||||
log(ctx, zerolog.InfoLevel, TypeAccess, kv...)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user