How to implement level based logging in golang?

2019-03-12 04:09发布

Is there any good wrapper available for level based logging in golang? If not, how should I go about implementing one myself?

What I want is pretty simple. I want a few functions e.g.

log.Error()
log.Info()

etc that display their outputs to stdout as well as save these in a log file (based on the level given to the program as commandline argument). How do I implement this wrapper?

标签: logging go
8条回答
孤傲高冷的网名
2楼-- · 2019-03-12 04:48

Take a look at http://cgl.tideland.biz and there at the package "applog". It's working that way.

PS: The whole CGL is currently reworked and will soon be released with new features, but under a different name. ;)

查看更多
劫难
3楼-- · 2019-03-12 04:49

I think seelog fits your requirements, and it seems to be pretty popular as it pops up often in log discussions. I never used it seriously, so I can't comment beyond that.

查看更多
登录 后发表回答