Skip to content
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

hertzzap流程优化建议 #1143

Closed
stonebirdjx opened this issue Jun 22, 2024 · 8 comments · Fixed by hertz-contrib/logger#53
Closed

hertzzap流程优化建议 #1143

stonebirdjx opened this issue Jun 22, 2024 · 8 comments · Fixed by hertz-contrib/logger#53
Labels
invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) stale

Comments

@stonebirdjx
Copy link

打印日志时能不能先判断日志级别呢? 设置info级别后, 分析pprof 还有CtxDebugf的性能消耗

@github-actions github-actions bot added the invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) label Jun 22, 2024
Copy link

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.

@github-actions github-actions bot added the stale label Jun 22, 2024
@li-jin-gou
Copy link
Member

cc @rogerogers

@li-jin-gou
Copy link
Member

本地复现

package main

import (
	"context"
	"github.com/cloudwego/hertz/pkg/common/hlog"
	hertzzap "github.com/hertz-contrib/logger/zap"
)

func main() {
	logger := hertzzap.NewLogger()
	hlog.SetLogger(logger)
	hlog.SetLevel(hlog.LevelInfo)

	hlog.CtxInfof(context.Background(), "hello %s", "hertz")
	hlog.CtxDebugf(context.Background(), "hello %s", "hertz")
	logger.Sync()
}

output:

{"level":"info","ts":1719048778.078252,"msg":"hello hertz"}

一切正常

@github-actions github-actions bot removed the stale label Jun 22, 2024
@rogerogers
Copy link
Contributor

没理解啥意思,等级判断是通过 level 的 Enabled 方法判断的,如果有必要可以自定义这个方法的逻辑

Copy link

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.

@rogerogers
Copy link
Contributor

理解了,感谢反馈,做了一版修正

@stonebirdjx
Copy link
Author

👍,感谢采纳,果然是中国速度

Copy link

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) stale
Development

Successfully merging a pull request may close this issue.

3 participants