hertz-contrib/logger

[bug] 使用hertzZerolog不能正确获取caller

Closed this issue · 2 comments

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.
image

hlog 会 warp 一层 zerolog ,导致计算 caller 文件行数的结果错了。

zap 也有同样的问题,caller 不对的话可以参考 uber-go/zap#715 (comment) 设置 option