MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / GetFileLineString

Method GetFileLineString

pkg/logger/logger.go:286–309  ·  view source on GitHub ↗

GetFileLineString will find the caller file and line number taking in to account the calldepth to iterate up the stack to find the non-logging call location.

(calldepth int)

Source from the content-addressed store, hash-verified

284// taking in to account the calldepth to iterate up the stack
285// to find the non-logging call location.
286func (l *Logger) GetFileLineString(calldepth int) string {
287 var file string
288 var line int
289 var ok bool
290
291 _, file, line, ok = runtime.Caller(calldepth)
292 if !ok {
293 file = "???"
294 line = 0
295 }
296
297 if l.flag&Lshortfile != 0 {
298 short := file
299 for i := len(file) - 1; i > 0; i-- {
300 if file[i] == '/' {
301 short = file[i+1:]
302 break
303 }
304 }
305 file = short
306 }
307
308 return fmt.Sprintf("%s:%d", file, line)
309}
310
311// FormatTimestamp returns a formatted timestamp.
312func (l *Logger) FormatTimestamp(ts time.Time) string {

Callers 1

formatLogMessageMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected