:sparkles: Proposal: Support New and SetCallerSkip func for hlog
Is your feature request related to a problem? Please describe.
en
At present, it is difficult for us to directly use hlog in business scenarios. First of all it is a public instance, any settings will take effect globally (not only business code, but also hertz). Secondly as the documentation says hlog it is difficult to encapsulate. This caused me to reimplement FullLogger even if I only needed a simple wrapper.
zh
目前我们很难在业务场景中直接使用hlog。
首先它是一个公共的实例,任何设置都将导致全局生效,(不仅在业务日志中生效,也包含hertz源码日志也生效)。
其次正如文档说的那样封装hlog可能会导致日志内容里文件名和行数不准确。这导致了即便我只需要简单封装,我也要重新实现FullLogger。
Describe the solution you'd like
en
Add a New func to create a different defaultLogger instance, add a SetCallerSkip func to specify the caller depth.
zh
增加一个New方法去创建不同的defaultLogger实例,增加SetCallerSkip方法去指定调用位置。
目前的这套日志确实有一定的局限性,这块如果有好的优化思路欢迎直接提出来一起看看哈;
目前的一些想法:
- 给hertz实例增加一个local logger(避免受全局配置的影响)
- 增加配置call depth的方式
@li-jin-gou 一起看看哈,最好是能出一个优化方案