feat: 添加两个函数,方便调试
This commit is contained in:
parent
fcba57c4e3
commit
9d7fea4d82
@ -10,6 +10,7 @@ package logger
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"go.uber.org/zap"
|
||||
@ -96,11 +97,12 @@ func ReplaceDefault(l *Logger) { std = l }
|
||||
|
||||
func SetLevel(level Level) { std.SetLevel(level) }
|
||||
|
||||
func With(fields ...Field) {
|
||||
std.l.Core().With(fields)
|
||||
func WithTarget(target string) Field {
|
||||
return String("target", target)
|
||||
}
|
||||
func WithRequestId(reqId string) {
|
||||
std.l.Core().With([]Field{String("reqId", reqId)})
|
||||
|
||||
func WithRequestId(req *http.Request) Field {
|
||||
return String("reqId", req.Header.Get("X-Request-ID"))
|
||||
}
|
||||
|
||||
func Debug(msg string, fields ...Field) { std.Debug(msg, fields...) }
|
||||
|
Loading…
Reference in New Issue
Block a user