Skip to content

Commit c5133f0

Browse files
committed
log: refactor callsite
Since we will use it later no with a different skip depth.
1 parent 005f76f commit c5133f0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

log.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ const calldepth = 3
174174

175175
// callsite returns the file name and line number of the callsite to the
176176
// subsystem logger.
177-
func callsite(flag uint32) (string, int) {
178-
_, file, line, ok := runtime.Caller(calldepth)
177+
func callsite(flag uint32, skipDepth int) (string, int) {
178+
_, file, line, ok := runtime.Caller(skipDepth)
179179
if !ok {
180180
return "???", 0
181181
}
@@ -204,7 +204,7 @@ func (b *Backend) print(lvl, tag string, args ...any) {
204204
var file string
205205
var line int
206206
if b.flag&(Lshortfile|Llongfile) != 0 {
207-
file, line = callsite(b.flag)
207+
file, line = callsite(b.flag, calldepth)
208208
}
209209

210210
formatHeader(bytebuf, t, lvl, tag, file, line)
@@ -231,7 +231,7 @@ func (b *Backend) printf(lvl, tag string, format string, args ...any) {
231231
var file string
232232
var line int
233233
if b.flag&(Lshortfile|Llongfile) != 0 {
234-
file, line = callsite(b.flag)
234+
file, line = callsite(b.flag, calldepth)
235235
}
236236

237237
formatHeader(bytebuf, t, lvl, tag, file, line)

0 commit comments

Comments
 (0)