- changed status to resolved
JSONLogger: fix incorrect caller when using Log function
There’s an occasional pattern where we have a function that takes a logging function e.g.
type Log func(level int8, msg string, args ...interface{})
// Dial connects to RTMP server specified by the given URL and returns the connection.
func Dial(url string, log Log, options ...func(*Conn) error) (*Conn, error) {
...
}
Instead of a logging.Logger interface,
func newRtmpSender(url string, retries int, rb *pool.Buffer, log logging.Logger, report func(sent int)) (*rtmpSender, error) {
In the prior cases, we pass the JSONLogger.Log method, but the problem is that the caller skip is tuned to the caller level corresponding to use of the wrappers (like JSONLogger.Debug(), JSONLogger.Info() etc) that call Log, not when Log is called directly. Therefore, the caller path in the resultant log is incorrect when this pattern is used. What we should do to fix this is create an internal JSONLogger.log method which both the logging wrappers e.g. JSONLogger.Debug(), JSONLogger.Info() and JSONLogger.Log wrap.
Comments (2)
-
reporter -
reporter Merged in fix-caller-skip (pull request #75)
jsonlogger: ensure logs have correct caller
Resolves issue
#48Approved-by: Trek Hopton Approved-by: David Sutton
→ <<cset b1af1a1d1674>>
- Log in to comment
Merged in fix-caller-skip (pull request #75)
jsonlogger: ensure logs have correct caller
Resolves issue
#48Approved-by: Trek Hopton Approved-by: David Sutton
→ <<cset 1beb6c6f71fc>>