remove the hardcode in runtime.Caller
Showing
1 changed file
with
5 additions
and
8 deletions
| ... | @@ -157,15 +157,12 @@ func (bl *BeeLogger) writerMsg(loglevel int, msg string) error { | ... | @@ -157,15 +157,12 @@ func (bl *BeeLogger) writerMsg(loglevel int, msg string) error { |
| 157 | lm.level = loglevel | 157 | lm.level = loglevel |
| 158 | if bl.enableFuncCallDepth { | 158 | if bl.enableFuncCallDepth { |
| 159 | _, file, line, ok := runtime.Caller(bl.loggerFuncCallDepth) | 159 | _, file, line, ok := runtime.Caller(bl.loggerFuncCallDepth) |
| 160 | if _, filename := path.Split(file); filename == "log.go" && (line == 97 || line == 83) { | 160 | if !ok { |
| 161 | _, file, line, ok = runtime.Caller(bl.loggerFuncCallDepth + 1) | 161 | file = "???" |
| 162 | } | 162 | line = 0 |
| 163 | if ok { | ||
| 164 | _, filename := path.Split(file) | ||
| 165 | lm.msg = fmt.Sprintf("[%s:%d] %s", filename, line, msg) | ||
| 166 | } else { | ||
| 167 | lm.msg = msg | ||
| 168 | } | 163 | } |
| 164 | _, filename := path.Split(file) | ||
| 165 | lm.msg = fmt.Sprintf("[%s:%d] %s", filename, line, msg) | ||
| 169 | } else { | 166 | } else { |
| 170 | lm.msg = msg | 167 | lm.msg = msg |
| 171 | } | 168 | } | ... | ... |
-
Please register or sign in to post a comment