[bug] 使用hertzZerolog不能正确获取caller
Closed this issue · 2 comments
nanakura commented
Describe the bug
使用hertzZerolog不能正确获取caller
To Reproduce
Steps to reproduce the behavior:
package main
import "os"
import (
"github.com/cloudwego/hertz/pkg/common/hlog"
hertzZerolog "github.com/hertz-contrib/logger/zerolog"
)
func main() {
hlog.SetLogger(hertzZerolog.New(
hertzZerolog.WithOutput(os.Stdout), // allows to specify output
hertzZerolog.WithLevel(hlog.LevelDebug), // option with log level
hertzZerolog.WithTimestamp(), // option with timestamp
hertzZerolog.WithCaller(),
))
hlog.Info("ok")
}
Expected behavior
日志的caller应为main.main
Screenshots
If applicable, add screenshots to help explain your problem.
li-jin-gou commented
hlog 会 warp 一层 zerolog ,导致计算 caller 文件行数的结果错了。
li-jin-gou commented
zap 也有同样的问题,caller 不对的话可以参考 uber-go/zap#715 (comment) 设置 option