Using the current caller depth skip function only outputs the tool method layer, making it impossible to pinpoint the actual problematic code. The reason is that the logging library by default skips the first 3 layers of calls, but in reality, reaching the actual call requires skipping 4 layers. To solve this problem, it is necessary to specify an additional caller skip layer when initializing the logger.
Current code(utils.go:44):
logger = level.NewFilter(logger, lvl) logger = log.With(logger, "timestamp", log.DefaultTimestampUTC, "caller", log.DefaultCaller)
Correct code:
logger = level.NewFilter(logger, lvl) logger = log.With(logger, "timestamp", log.DefaultTimestampUTC, "caller", log.Caller(4))
Using the current caller depth skip function only outputs the tool method layer, making it impossible to pinpoint the actual problematic code. The reason is that the logging library by default skips the first 3 layers of calls, but in reality, reaching the actual call requires skipping 4 layers. To solve this problem, it is necessary to specify an additional caller skip layer when initializing the logger. Current code(utils.go:44):
logger = level.NewFilter(logger, lvl) logger = log.With(logger, "timestamp", log.DefaultTimestampUTC, "caller", log.DefaultCaller)
Correct code:logger = level.NewFilter(logger, lvl) logger = log.With(logger, "timestamp", log.DefaultTimestampUTC, "caller", log.Caller(4))