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