charmbracelet/log

Set report caller to true only for certain log levels

Closed this issue · 1 comments

For instance I want to set:

  • log.SetReportCaller(true) for log.warn and log.error`
  • log.SetReportCaller(false) for all other log levels

Is it possible easily?

Hi @coin-au-carre, you can achieve that by using two Log instances, one with SetReportCaller(true) and SetLevel(WarnLevel), and the other with default values. Then wrap them in your custom type and override the Warn method to use the appropriate logger. Hope this helps 🙂