gRPC-go disable - minimise logging?

blov · 2017-03-15 15:00:13 · 927 次点击    
这是一个分享于 2017-03-15 15:00:13 的资源,其中的信息可能已经有所发展或是发生改变。

I've been having a real struggle with gRPC-go and being so verbose and know they plan to add different verbosity levels - however has anyone else experienced this and come up with a reasonable solution?

I am mostly referring to how when you call something to the nature of:

client.Close()

causes the server to log:

transport: http2Server.HandleStreams failed to read frame: read tcp 127.0.0.1:50001->127.0.0.1:50829: read: connection reset by peer

on what appears to be exponential back-off.


评论:

schumacherfm:

Build your own log wrapper and add it like:

grpclog.SetLogger(grpcLogTestWrap{})

I'm using that pattern while testing gRPC backends for an ESI tag middleware.

I also hate their global logger. Terrible pattern for a library.

nastus:

Thanks!

pbo_:

You can set your own gRPC logger using:

google.golang.org/grpc/grpclog.SetLogger()

But be aware that it must be called from init() functions only.

You can check out etcd sources to see how CoreOS guys have overcome this limitation: https://github.com/coreos/etcd/blob/master/clientv3/logger.go

nastus:

That's a good real world example, thanks :)


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

927 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传