TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Simple logger and debugger for Go programs

32 点作者 apsdehal超过 10 年前

8 条评论

AYBABTME超过 10 年前
Colorized output by default will make for messy logs that can&#x27;t be used. Sure you can turn it off (with an integer, why not a bool?), but that shouldn&#x27;t be something compiled in your program. Also there are no means to `printf` strings from the logger.<p>Finally, there are already a plethora of loggers for Go. I&#x27;d recommend logrus for structured logs:<p><a href="https://github.com/Sirupsen/logrus" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Sirupsen&#x2F;logrus</a><p>Or glog otherwise.<p>And a note: a logger isn&#x27;t a debugger. GDB is a debugger for Go, see <a href="https://golang.org/doc/gdb" rel="nofollow">https:&#x2F;&#x2F;golang.org&#x2F;doc&#x2F;gdb</a><p>Sorry if I come across as heartless, it&#x27;s nice to see new people coming to Go. But I don&#x27;t think this is novel or news worthy.
Queue29超过 10 年前
A wise gopher would use Rob Pikes glog package instead <a href="https://github.com/golang/glog" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;glog</a>
jacobkranz超过 10 年前
I&#x27;ve been trying to find a small logger program for Go and haven&#x27;t had time to write my own. Looks great and may start using it :)<p>The one minor issue is there is a syntax error in the readme. Should be import &quot;github.com&#x2F;apsdehal&#x2F;go-logger&quot;, not &quot;go get github.com&#x2F;apsdehal&#x2F;go-logger&quot;
yourabi超过 10 年前
This looks interesting - I&#x27;ll take a closer look.<p>You might want to check out the logrus package - which I&#x27;m using and pretty happy with. <a href="https://github.com/sirupsen/logrus" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sirupsen&#x2F;logrus</a><p>Logrus lets you add structured k,v fields so you do have to mess around with fmt and also has hooks to support things like sending logs to syslog or remote exception handling services.
评论 #8381209 未加载
NateDad超过 10 年前
Does this only output to stdout? It would be useful if it took an io.Writer so you could write to a file or something else, too.
NateDad超过 10 年前
Btw, anyone interested in loggers should check out my log rolling package gopkg.in&#x2F;natefinch&#x2F;lumberjack.v2
latch超过 10 年前
It&#x27;s a shame there&#x27;s no basic interface in the go&#x27;s log package.
2mur超过 10 年前
package =&#x2F;= repo name<p>Don&#x27;t do that
评论 #8380957 未加载