-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logrusLogger.SetReportCaller 设置问题 #18
Comments
有解决方案吗? 用 kitex 微服务开发 打印日志后,如果没有对应的文件和 行号,定位代码位置的效率比较低 |
可以参考下这个,is-it-possible-to-wrap-logrus-logger-functions-without-losing-the-line-number-pr,另外zap的话有自带
|
有使用示例吗? |
logrus可以简单看下这里。 zap就比较简单了。 package main
import (
"context"
"github.com/cloudwego/hertz/pkg/common/hlog"
hertzzap "github.com/hertz-contrib/logger/zap"
"go.uber.org/zap"
)
func main() {
logger := hertzzap.NewLogger(hertzzap.WithZapOptions(zap.WithCaller(true), zap.AddCallerSkip(2)))
hlog.SetLogger(logger)
hlog.CtxInfof(context.Background(), "hello %s", "hertz")
} |
示例我用的hertz,kitex代码差不多的。 |
已解决 |
这个讲的啥?要的是日志打印的来源文件,这说的啥???? |
解决方案就是调整runtime信息来输出日志打印位置,有什么疑问可以具体描述下? |
目的:打印 出来 所在的文件 和行号
使用
打印出来 是 obs-opentelemetry/logging/logrus@v0.0.0-20221109071748-a433b0b57972/logger.go:93 是 这个位置,不是 实际业务代码的位置,这个有办法解决吗?
The text was updated successfully, but these errors were encountered: