gRPC-go disable - minimise logging?

blov · · 794 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;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?</p> <p>I am mostly referring to how when you call something to the nature of:</p> <pre><code>client.Close() </code></pre> <p>causes the server to log:</p> <pre><code>transport: http2Server.HandleStreams failed to read frame: read tcp 127.0.0.1:50001-&gt;127.0.0.1:50829: read: connection reset by peer </code></pre> <p>on what appears to be exponential back-off.</p> <hr/>**评论:**<br/><br/>schumacherfm: <pre><p>Build your own log wrapper and add it like:</p> <pre><code>grpclog.SetLogger(grpcLogTestWrap{}) </code></pre> <p>I&#39;m using that pattern while testing gRPC backends for an ESI tag middleware.</p> <p>I also hate their global logger. Terrible pattern for a library.</p></pre>nastus: <pre><p>Thanks! </p></pre>pbo_: <pre><p>You can set your own gRPC logger using:</p> <p>google.golang.org/grpc/grpclog.SetLogger()</p> <p>But be aware that it must be called from init() functions only.</p> <p>You can check out etcd sources to see how CoreOS guys have overcome this limitation: <a href="https://github.com/coreos/etcd/blob/master/clientv3/logger.go" rel="nofollow">https://github.com/coreos/etcd/blob/master/clientv3/logger.go</a></p></pre>nastus: <pre><p>That&#39;s a good real world example, thanks :)</p></pre>

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

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