-
Notifications
You must be signed in to change notification settings - Fork 142
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
bug反馈 #31
Comments
3: |
@Xihuyouyu memory只是一个本地开发方案,不推荐生产环境使用,并且也有别的成熟方案有兴趣可以自己扩展一种,这些都是支持的。 |
@Xihuyouyu 反馈的bug1,局限于go的静态语言的问题,引入依赖注入又过于臃肿,等待后续泛型加入主版本,再优化这里 |
@Xihuyouyu 反馈的bug2,在没有用队列的情况下是有这种风险的,目前go-admin的日志写入已经通过队列优化了。 |
get |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bug1:
代码位置: /sdk/pkg/logger/log.go :49
说明: plugins/logger/zap包里对 output的赋值是取自上下文Context,当前代码的logger.WithOutput(output)无效,无法正确设置日志的输出,应该使用 zap包的zap.WithOutput.
bug2:
代码位置: /debug/writer/file.go :104
说明: 在日志库使用zaplog(/plugins/logger/zap/)的情况下有数据被覆盖的风险。代码/plugins/logger/zap/zap.go :58 使用了 zapcore.NewConsoleEncoder(), zap在写入日志数据的时候使用了 sync.pool,代码参见 go.uber.org/zap/zapcore/console_encoder.go :67, 在并发情况下,FileWriter.Write()将data1 []byte写入管道 FileWriter.input, 在数据被真正写入 FileWriter.file.Write()前, zap从对象池重新取出buffer并赋值, 生成data2 []byte,,如果两次取出的buffer地址相同,那么管道内data1的数据会被data2覆盖,导致日志的输出异常。
The text was updated successfully, but these errors were encountered: