You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2016-10-12 00:31:57.373672 [pre] INFO play/main.go:15 test
2016-10-12 00:31:57.373835 [pre] INFO play/main.go:16 test
2016-10-12 00:31:57.373841 [pre] WARNING play/main.go:17 test
2016-10-12 00:31:57.373846 [pre] INFO play/main.go:18 test
2016-10-12 00:31:57.373855 [pre] ERROR play/main.go:19 test
需求描述
现在想把logger写在struct中,例如:
然后我可以在new 这个struct的时候同时new一个 logger ,然后给他set tag, 标准库的log是这样的:
这样,store的log我可以这样写
store.logger.Errorf("message")
, sore 打出来的log都会有[store]
前缀。每个包的最终日志写到一起不变。原有的log方式希望也能保持,只是新增支持打tag。问题:
现在是一个全局logger, 如果一个struct设置tag会不会影响其他struct的。
The text was updated successfully, but these errors were encountered: