How to adjust the caller frame in log messages
This guide describes a feature of the github.com/go-nacelle/log
package. See related documentation.
Sometimes it is useful to define helper functions that logs messages for you in a common way (applying common context, performing additional behavior on errors, etc). Unfortunately, this can interfere with the way the caller file and line number are discovered. The logger has a WithIndirectCaller
method that will increase the depth used when scanning the stack for callers. This should be used at each log location that aggregates log calls (e.g. any place where knowing this source location would not be helpful).
|
|
Using a logger instance directly does not require this additional hint.