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)
| 284 | // taking in to account the calldepth to iterate up the stack |
| 285 | // to find the non-logging call location. |
| 286 | func (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. |
| 312 | func (l *Logger) FormatTimestamp(ts time.Time) string { |