包装日志支持传入skip
This commit is contained in:
parent
38a2e3b582
commit
cdf75b507b
@ -27,8 +27,8 @@ import (
|
|||||||
// Author : go_developer@163.com<张德满>
|
// Author : go_developer@163.com<张德满>
|
||||||
//
|
//
|
||||||
// Date : 9:56 下午 2021/3/1
|
// Date : 9:56 下午 2021/3/1
|
||||||
func NewGormV2(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.Encoder, splitConfig *logger2.RotateLogConfig, traceIDField string) (logger.Interface, error) {
|
func NewGormV2(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.Encoder, splitConfig *logger2.RotateLogConfig, traceIDField string, skip int) (logger.Interface, error) {
|
||||||
logConfList := []logger2.SetLoggerOptionFunc{logger2.WithEncoder(encoder), logger2.WithCallerSkip(3), logger2.WithCaller()}
|
logConfList := []logger2.SetLoggerOptionFunc{logger2.WithEncoder(encoder), logger2.WithCallerSkip(skip), logger2.WithCaller()}
|
||||||
if consoleOutput {
|
if consoleOutput {
|
||||||
logConfList = append(logConfList, logger2.WithConsoleOutput())
|
logConfList = append(logConfList, logger2.WithConsoleOutput())
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,12 @@ import (
|
|||||||
// Author : go_developer@163.com<张德满>
|
// Author : go_developer@163.com<张德满>
|
||||||
//
|
//
|
||||||
// Date : 3:45 下午 2021/1/3
|
// Date : 3:45 下午 2021/1/3
|
||||||
func NewGinLogger(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.Encoder, splitConfig *logger.RotateLogConfig, extractFieldList []string) (*Gin, error) {
|
func NewGinLogger(loggerLevel zapcore.Level, consoleOutput bool, encoder zapcore.Encoder, splitConfig *logger.RotateLogConfig, extractFieldList []string, skip int) (*Gin, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
l *zap.Logger
|
l *zap.Logger
|
||||||
)
|
)
|
||||||
logConfList := []logger2.SetLoggerOptionFunc{logger2.WithEncoder(encoder), logger2.WithCaller(), logger2.WithCallerSkip(1)}
|
logConfList := []logger2.SetLoggerOptionFunc{logger2.WithEncoder(encoder), logger2.WithCaller(), logger2.WithCallerSkip(skip)}
|
||||||
if consoleOutput {
|
if consoleOutput {
|
||||||
logConfList = append(logConfList, logger2.WithConsoleOutput())
|
logConfList = append(logConfList, logger2.WithConsoleOutput())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user