(calldepth int, depth int)
| 360 | } |
| 361 | |
| 362 | func formatCallpath(calldepth int, depth int) string { |
| 363 | v := "" |
| 364 | callers := make([]uintptr, 64) |
| 365 | n := runtime.Callers(calldepth+2, callers) |
| 366 | oldPc := callers[n-1] |
| 367 | |
| 368 | start := n - 3 |
| 369 | if depth > 0 && start >= depth { |
| 370 | start = depth - 1 |
| 371 | v += "~." |
| 372 | } |
| 373 | recursiveCall := false |
| 374 | for i := start; i >= 0; i-- { |
| 375 | pc := callers[i] |
| 376 | if oldPc == pc { |
| 377 | recursiveCall = true |
| 378 | continue |
| 379 | } |
| 380 | oldPc = pc |
| 381 | if recursiveCall { |
| 382 | recursiveCall = false |
| 383 | v += ".." |
| 384 | } |
| 385 | if i < start { |
| 386 | v += "." |
| 387 | } |
| 388 | if f := runtime.FuncForPC(pc); f != nil { |
| 389 | v += formatFuncName(fmtVerbShortfunc, f.Name()) |
| 390 | } |
| 391 | } |
| 392 | return v |
| 393 | } |
| 394 | |
| 395 | // backendFormatter combines a backend with a specific formatter making it |
| 396 | // possible to have different log formats for different backends. |
no test coverage detected